你能为 ubuntu 上的 nodejs 推荐一个 upstart 配置文件吗?我找到了以下教程:http://howtonode.org/deploying-node-upstart-monit但它看起来很旧。
请您参考如下方法:
我有一个小的 shell 脚本来创建我的配置文件。
create_upstart() {
project=$1
file=$2
conf="/etc/init/${project}_${file}.conf"
cat > $conf << EOF
#!upstart
description "Node Process - $1"
author "Geert Pasteels"
respawn
start on (local-filesystems and net-device-up IFACE=eth0)
stop on shutdown
script
export NODE_ENV="production"
export PORT="3001"
exec /usr/bin/node /var/www/$project/current/$file.js >> /var/www/$project/shared/logs/$file 2>&1
end script
EOF
echo $conf
# Restart upstart script
stop ${project}_${file}
start ${project}_${file}
echo Restarted ${project}_${file}
}
create_upstart "$1" "$2"
我将它与 TJ's deploy 结合使用.所以在我的部署后 Hook 中,我执行 startup app file.