編寫你的新貴指令碼

你需要在/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