What is Procfile? and Web and Worker

node.jsMongodbHerokuProcfile

node.js Problem Overview


Is it necessary to give 'worker' information in Procfile? If yes then what it is actually? I have already added web: node server/server.js detail in the Procfile.

node.js Solutions


Solution 1 - node.js

> Procfile is a mechanism for declaring what commands are run by your application’s dynos on the Heroku platform.

From Process Types and the Procfile, which is a good introduction, but basically you use the Procfile to tell Heroku how to run various pieces of your app. The part to the left of the colon on each line is the process type; the part on the right is the command to run to start that process.

Process types can be anything, although web is special, as Heroku will route HTTP requests to processes started with the web name. Other processes, such as background workers, can be named anything, and you can use the Heroku toolbelt to start or stop those processes by referring to its name.

So, in short, worker is not necessary, unless you want to run some other process in the background by controlling process with the heroku ps command.

Solution 2 - node.js

You would only need a 'worker' entry in your Procfile if you plan on using some sort of background job system (i.e. queuing long running tasks for later). Heroku has more information here:

https://devcenter.heroku.com/articles/procfile

Solution 3 - node.js

I was following Udemy course regarding nestjs and aws Elastic Beanstalk to deploy however it keeps failing to deploy until I created Procfile with following:

web: npm install && npm run-script build && npm run-script start:prod

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMaulik SuchakView Question on Stackoverflow
Solution 1 - node.jsMichelle TilleyView Answer on Stackoverflow
Solution 2 - node.jsKevin SylvestreView Answer on Stackoverflow
Solution 3 - node.jsAkeshmaView Answer on Stackoverflow