バージョン8.04「Hardy」であるubuntuマシン用のupstartスクリプトを作成しようとしています。このサイトの指示に従いました: node.js の upstart ですが、これらの指示は ubuntu の現在のバージョン用のようです。
/etc/init ディレクトリが自分のマシンに存在しないことに気付きました。最初にスクリプトを /etc/init.d ディレクトリに配置してから、/etc/init ディレクトリを作成してそこに配置しました。
以下に自分のアップスタート スクリプトを投稿します (基本的には上記の Web サイトと同じですが、いくつかのパスが変更されています)。ただし、start jobname を実行すると、「start: Unknown job: jobname」というエラーが表示されます。そこで、スクリプトをスリム化したバージョンに変更し、以下に投稿しましたが、それでも同じ結果が得られます。
今のところ、「nohup」コマンドを使用してノード サーバーを実行していますが、より恒久的なソリューションが必要です。
助けてください。
スクリプト 1:
description "node.js chat server"
author "iandev ith3"
# 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 /root/local/node/bin/node /home/ian/chat.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
スクリプト 2:
description "node.js chat server"
author "iandev ith3"
script
exec /root/local/node/bin/node /home/ian/chat.js >> /var/log/node.log 2>&1
end script