I've set up a NodeJS App which works great when I run it on an ubuntu server with:
nodejs /var/www/html/bin/www
Then I've set up an upstart /etc/init/myApp.conf
containing:
#!upstart
author "Matt"
description "myApp"
setuid "ubuntu"
start on (local-filesystems and net-device-up IFACE=eth0)
stop on shutdown
respawn
console log
env NODE_ENV=production
exec nodejs /var/www/html/bin/www
Then when I run it sudo start myApp
I get myApp start/running, process 5862
which usually it would tell me that it is running but when I stop it sudo stop myApp
I get stop: Unknown instance:
which I guess means it isn't running.
Additionally when I access the server via a browser I get 502 Bad Gateway
just like when node is not running.
Is there anything obvious that I'm missing here?
We had used Ubuntu upstart to start node service as server is booted. But we faced several issues in upstart, also it was hard to debug and maintain. We then shifted to PM2
which is the best process manager for node.js applications till date and has great community support being the widely used process manager.
So if your only purpose of using ubuntu upstart is to start the service on bootup. I would suggest you to consider using PM2.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.