Reputation: 3965
I've started the "node start" via supervisord.
My problem is Stopping / rebooting at supervisord will cause the node app.js process to remain without being killed
How can supervisord restart the npm start command successfully in this case?
supervisord.conf
[supervisord]
nodaemon=true
[program:node]
command=npm start
directory=/xx
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
user=root
autostart=true
autorestart=true
redirect_stderr=true
exitcodes=1
package.json
{
"name": "xx",
"version": "1.0.0",
"main": "app.js",
"scripts": {
"start": "node app.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"xxx
},
"devDependencies": {
"nodemon": "^1.11.0"
},
"description": ""
}
Upvotes: 4
Views: 3552
Reputation: 9273
This worked for me: change npm start
to node app.js
inside the Supervisor config file.
I've noticed that using npm start
starts two processes:
$ ps aux | grep node
ubuntu 19363 0.0 0.0 4508 708 ? S 17:43 0:00 sh -c node index.js
ubuntu 19364 1.3 5.2 1041288 52996 ? Sl 17:43 0:00 node index.js
And stopping it in Supervisor only stops the parent process:
$ sudo supervisorctl stop all
my_worker: stopped
$ ps aux | grep node
ubuntu 19364 0.3 5.2 1041288 52996 ? Sl 17:43 0:00 node index.js
So putting node index.js
directly in the supervisor config solved the problem for me.
Upvotes: 5