/etc/init
以下にyourprogram.confとしてファイル作成
#yourprogram.conf
description "node.js server"
author "kvz - http://kevin.vanzonneveld.net"
# 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
# Not sure why $HOME is needed, but we found that it is:
export HOME="/root"
exec sudo -u www-data /usr/bin/node /where/yourprogram.js >> /var/log/node.log 2>&1
end script
post-start script
# Optionally put a script here that will notifiy you node has (re)started
# /root/bin/hoptoad.sh "node.js has started!"
end script
##/usr/local/bin/node → /usr/bin/nodeに修正
## ユーザwww-dataは作成しておく
init-checkconf /etc/init/yourprogram.conf
を実行してみる
failed to ask Upstart to check conf fileと出るが
/tmpフォルダにinit-checkconf-upstart-outputが出力されているので
何もエラーがなければOkのはず
下記コマンドで実行
start yourprogram
停止
stop yourprogram
0 件のコメント:
コメントを投稿