我们有一个由Upstart管理的node.js/express/socket.io服务器。 “停止的NodeJS”,其中是的NodeJS包含以下内容新贵脚本:服务器通过在bash运行此命令停止在退出之前在node.js中清理
#!upstart
description "node.js"
# Start the job
start on runlevel [2345]
# Stop the job
stop on runlevel [016]
# Restart the process if it dies
respawn
script
cd /var/www/node_server/
exec /usr/local/node/bin/node /var/www/node_server/chatserver.js >> /var/www/node_server/chatserver.log 2>&1
end script
post-start script
# Optionally put a script here that will notify you node has (re)started
# /root/bin/hoptoad.sh "node.js has started!"
end script
我们想执行服务器停止类似权利之前一些清理工作上文提到的。我们尝试了process.on('exit'...)和process.on('SIGINT'...),但都无济于事。
如何在服务器停止之前调用回调权限?
你能否澄清'stop nodejs',你在哪里运行?你如何运行它? – Bamieh
是的。请看我的新编辑。 –