I'm running version 3.3.1
.
Apart of my /etc/supervisor/supervisord.conf
file:
[program:node]
directory=/srv/www
command=npm run demo
autostart=true
autorestart=true
Apart of my package.json
file under scripts:
"demo": "npm run prod",
"prod": "NODE_ENV=production NODE_PATH=\"$(pwd)\" node src/index.js"
I attempt to shutdown the node program via supervisorctl
, however it persists.
root@dev-demo-karl:/srv/www# ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.2 0.8 50280 18404 ? Ss 08:43 0:00 /usr/bin/python /usr/bin/supervisord
root 8 0.2 2.4 1003412 49456 ? Sl 08:43 0:00 npm
root 16 0.9 2.3 295224 47704 ? SLl 08:43 0:02 /usr/bin/mongod --auth --fork --smallfiles --logpath /var/log/mongodb.log
root 44 0.0 0.0 4512 808 ? S 08:43 0:00 sh -c npm run prod
root 45 0.2 2.4 1003924 49628 ? Sl 08:43 0:00 npm
root 56 0.0 0.0 4512 716 ? S 08:43 0:00 sh -c NODE_ENV=production NODE_PATH="$(pwd)" node src/index.js
root 60 1.5 7.0 1069880 145108 ? Sl 08:43 0:04 node src/index.js
root 96 0.0 0.1 18244 3340 ? Ss 08:44 0:00 bash
root 134 0.0 0.1 34424 2896 ? R+ 08:48 0:00 ps aux
root@dev-demo-karl:/srv/www# supervisorctl
mongod FATAL Exited too quickly (process log may have details)
node RUNNING pid 8, uptime 0:05:04
supervisor> stop node
node: stopped
supervisor> status
mongod FATAL Exited too quickly (process log may have details)
node STOPPED May 05 08:48 AM
supervisor> exit
root@dev-demo-karl:/srv/www# ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.2 0.9 50280 18448 ? Ss 08:43 0:00 /usr/bin/python /usr/bin/supervisord
root 16 0.9 2.3 296324 47704 ? SLl 08:43 0:03 /usr/bin/mongod --auth --fork --smallfiles --logpath /var/log/mongodb.log
root 45 0.2 2.4 1003924 49628 ? Sl 08:43 0:00 npm
root 56 0.0 0.0 4512 716 ? S 08:43 0:00 sh -c NODE_ENV=production NODE_PATH="$(pwd)" node src/index.js
root 60 1.4 7.0 1069880 143996 ? Sl 08:43 0:04 node src/index.js
root 96 0.0 0.1 18244 3340 ? Ss 08:44 0:00 bash
root 136 0.0 0.1 34424 2892 ? R+ 08:48 0:00 ps aux
I'm wondering how do I setup supervisor with a node npm script properly. The internet guides have shown nothing but what I've done above. I have no control over stopping/starting it.
I solved this by creating a script in my package.json like this:
This will work if you have supervisor installed in your global scope.
Now all I do is: npm run start-continuous
I hope this helps.