编写你的新贵脚本
你需要在/etc/init/ directory
中使用 upstart 脚本。使用你的应用程序名称命名,以 .conf
结尾,例如/etc/init/myapp.conf
。基本的 upstart 脚本看起来像这样:
## /etc/init/myapp.conf
description "myapp.mydomain.com"
author "somebody@gmail.com"
# Automatically Run on Startup
start on started mountall
stop on shutdown
# Automatically Respawn:
respawn
respawn limit 99 5
script
export HOME="/root"
export MONGO_URL='mongodb://myapp.compose.io:27017/meteor'
export ROOT_URL='http://myapp.mydomain.com'
export PORT='80'
exec /usr/local/bin/node /var/www/myapp/main.js >> /var/log/myapp.log 2>&1
end script