Heroku multiple web processes - node.js

I am working with node.js and heroku and would like to have more than one webprocess running.
In the Procfile I have it looking like this:
web: node web.js
web: node differentWeb.js
However when I run it it will only run the last of the two. Is there a way to do this?

An application on Heroku can only have one process named web that gets routed HTTP requests. If you need another web process then that would be another application on Heroku.

Related

Nextjs seperate process for frontend and backend

I am using custom server in nextjs. Everytime I make a change in the frontend or backend, nodemon restarts the main process and the child processes. This results in an increased build time.
My expectation is that when I make a change in the pages or other frontend component, the already running server and the database connection should not restart.
How can this be achieved?
I think if I run the custom server seperatly and use rewrites in next.config then I can have the two server running seperatly.
GetStaticProps, GetStaticPaths, GetServerSideProps, and GetInitialProps all execute serverside. Actually, unless the component returns JSX it executes on the server. So you have client side and serverside in each pages file, and all serverside in _app and _document. Nextjs has fast refresh so nodemon isn't necessary with Next. Try removing nodemon and just run with yarn next dev or npm run next dev, fast refresh is built in

Will requests get lost during initialization of Node.JS app on Heroku?

I have a Facebook Messenger bot written with Node.JS. Currently, it initializes the database (and cache) before initializing Express and receiving requests. I wonder if some requests are sent during initialization, will they get lost?
I'm using Heroku, it that matters.
For free or hobby dyno in heroku there is no zero-downtime setup or preboot as a feature available. While deployment, your Node.js dyno will not serve
the incoming request from the point it restarts the process on that dyno till your server is running successfully on the specified port.
If you have zero-downtime setup already, then your requests will be served by
previous deployed instance unless the new one is spawn and ready to serve.
here is reference link for more info. on zero-downtime heroku

How to update page information of Nodejs app deployed using Heroku free hosting on a daily basis?

I have a nodejs app which needs to fetch some data (download a picture to the server and fetch some related text) from an API once a day at midnight and updates the fields my index.ejs file.
Unfortunately because of restrictions around the free Heroku accounts, my app goes to sleep after 30 minutes of inactivity, so I can't use a cron-job for this.
I tried heroku scheduler, but it doesn't work. I added node server.js as a job, but it doesn't run it. I tried removing the job and adding it again, but it didn't work. My app runs fine in local environment, or when I initially push it to heroku, or when I do heroku run node server.js.
I tried the creating a separate server file with no JS extension and added #!/usr/bin/env node to the but it said "bash command not found" when I tried to heroku run node server.js.
I'm really confused. Any help will be appreciated.
Cheers

Parse Server on Heroku Running on Web Worker Dynos

I am running a parse server on a heroku web dyno. I need to run a long requests on a worker dyno. Do I need to run two parse servers, one for web and one for the worker dyno?
How would one go about running worker dynos when working with parse? I see an example of a nodejs worker, but not sure if it applies to a parse server.

How can I keep a Node app running on Heroku which is not a server without providing $PORT?

I've written a web scraper using node.js which scrapes a particular website, gets some data from there and then tweets it. I've deployed this app on Heroku and app crashes by giving an error that $PORT couldn't be bound within 60 seconds. I've tried putting both worker: node index.js and web: node index.js in Procfile one by one, but it crashes.
Since my app is not a server hence does not need a port number, how can I keep it running with out making my app a server?
Turn on the worker process and off the default web process:
$ heroku scale web=0 worker=1
Take a look at the following link: http://pm2.keymetrics.io/docs/usage/use-pm2-with-cloud-providers/

Resources