Nodejs app not using Procfile but npm start instead

945 views Asked by At

I run an nodejs express server on Heroku. I define a Procfile in my application root which contains:

web:node --optimize_for_size --max_old_space_size=460 --gc_interval=100 server.js

However when I use heroku logs -a my-app --tail I noticed that my app is started using npm start which is only node server.js and not what I put inside my Procfile. Here is the log:

2020-05-20T16:28:35.000000+00:00 app[api]: Build succeeded
2020-05-20T16:28:36.489864+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2020-05-20T16:28:36.575077+00:00 heroku[web.1]: Process exited with status 143
2020-05-20T16:28:37.695081+00:00 heroku[web.1]: Starting process with command `npm start`
2020-05-20T16:28:40.709631+00:00 app[web.1]: 
2020-05-20T16:28:40.709647+00:00 app[web.1]: > [email protected] start /app
2020-05-20T16:28:40.709648+00:00 app[web.1]: > node server.js
2020-05-20T16:28:40.709648+00:00 app[web.1]: 

As I understand from Heroku's documentation, npm start should only be used if there is no Procfile detected. What am I missing here?

1

There are 1 answers

0
Jonas Pauthier On

The problem was that I didn't have a space between my process name and the command inside my Procfile. This works for me now:

web: node --optimize_for_size --max_old_space_size=460 --gc_interval=100 server.js

Here is the log output from heroku logs:

2020-05-20T16:58:44.000000+00:00 app[api]: Build succeeded
2020-05-20T16:58:46.235387+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2020-05-20T16:58:46.360055+00:00 heroku[web.1]: Process exited with status 143
2020-05-20T16:58:47.111612+00:00 heroku[web.1]: Starting process with command `node --optimize_for_size --max_old_space_size=460 --gc_interval=100 server.js`