副本集的 Upstart 指令碼
如果你正在執行副本集或需要對資料庫進行分片,那麼你需要一個看起來像這樣的 upstart 指令碼:
# /etc/init/myapp.conf
description "myapp.mydomain.com"
author "somebody@gmail.com"
# used to be: start on startup
# until we found some mounts weren't ready yet while booting:
start on started mountall
stop on shutdown
# Automatically Respawn:
respawn
respawn limit 99 5
script
# upstart likes the $HOME variable to be specified
export HOME="/root"
# our example assumes you're using a replica set and/or oplog integreation
export MONGO_URL='mongodb://mongo-a,mongo-b,mongo-c:27017/?replicaSet=meteor'
# root_url and port are the other two important environment variables to set
export ROOT_URL='http://myapp.mydomain.com'
export PORT='80'
exec /usr/local/bin/node /var/www/production/main.js >> /var/log/node.log 2>&1
end script