使用 upstart 啟動 node.js 的常駐程式
# /etc/init/autopatch.conf description "autopatch service" start on (local-filesystems and net-device-up) stop on shutdown respawn # restart when job dies respawn limit 10 5 # give up restart after 5 respawns in 5 seconds script export NODE_PATH="/usr/lib/node_modules/" export HOME="/root" export NODE_ENV="production" exec /usr/bin/node /home/www/node.js/autopatch/server.js >> /var/log/node.js/autopatch.log 2>&1 end script
而日後只要下以下指令
start autopatch (啟動)
restart autopatch (重啟)
stop autopatch (停止)
相當的方便