私はmeteorjsを学び、小さなリモートVPSを持っています。
が欲しいです:
- 私のmeteorプロジェクトのgitリポジトリからの自動プルを設定します。
- 私のmeteorプロジェクトをサービスとして実行するスクリプトを自動開始に入れます。
例えば
meteor run -p 80 -- production
私のサーバーはUbuntu12.04です
私はmeteorjsを学び、小さなリモートVPSを持っています。
が欲しいです:
例えば
meteor run -p 80 -- production
私のサーバーはUbuntu12.04です
UpstartであるUbuntuの方法を使用する必要があります。
http://upstart.ubuntu.com/ http://manpages.ubuntu.com/manpages/lucid/man5/init.5.html
デーモンジョブを定義する方法:
http://newcome.wordpress.com/2012/02/26/running-programs-as-linux-daemons-using-upstart/
それが役に立てば幸い :)
upstartファイルは多かれ少なかれ次のようになります。
# meteorjs - meteorjs job file
description "MeteorJS"
author "Igor S"
# When to start the service
start on runlevel [2345]
# When to stop the service
stop on runlevel [016]
# Automatically restart process if crashed
respawn
# Essentially lets upstart know the process will detach itself to the background
expect fork
# Run before process
pre-start script
cd PATH_TO_METEOR_APP
echo ""
end script
# Start the process
exec meteor run -p 80 --help -- production
これが私がすることです:
description "meteor app server"
start on runlevel [2345]
stop on runlevel [06]
respawn
respawn limit 10 5
pre-start script
set -e
rm -f /path/to/your/app/.meteor/local/db/mongod.lock
end script
exec /bin/su - ec2-user -c '/path/to/your/app/meteor_server.sh'
post-stop script
pkill -f meteor
end script
meteor_server.sh
スクリプトには次のものが含まれます。
cd /path/to/your/app/; meteor run -p 3000 --production
スクリプトを確認しchmod +x
、meteor_server.sh
3つの場所でアプリへのパスを変更してください。また、スクリプトは停止時にすべての流星タスクを強制終了するため、サーバー上でのみ単一の流星アプリを実行するために機能します。nginxを使用してこの方法でmeteorアプリをすばやく実行しましたが、ノードは大量のメモリを消費しているようです。
これは私のmeteorjs.confファイルです-正常に動作します。私は以前にすべての問題を説明しましたが、このバリアントはそれらを修正します。それが誰かを助けることを願っています:)
私が得たすべてのEXPORT
変数printenv
# meteorjs - meteorjs job file
description "MeteorJS"
author "Alex Babichev"
# When to start the service
start on runlevel [2345]
# When to stop the service
stop on runlevel [016]
# Automatically restart process if crashed
respawn
# Essentially lets upstart know the process will detach itself to the background
expect fork
chdir /home/dev/www/test
script
export MONGO_URL=mongodb://localhost:27017/meteor
export PATH=/opt/local/bin:/opt/local/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
export PWD=/home/sputnik
export NODE_PATH=/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript
export HOME=/home/sputnik
echo "---- start ----"
cd /home/dev/www/test
exec mrt
end script