我学习meteorjs并且我有一个小型远程VPS。
我想:
例如
meteor run -p 80 -- production
我的服务器是Ubuntu 12.04
答案 0 :(得分:13)
你应该使用Ubuntu方式,即Upstart:
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/
希望有所帮助:)
你的新贵文件会更多或更少:
# 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
答案 1 :(得分:4)
以下是我的工作:
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以这种方式快速运行流星应用程序,但节点似乎消耗了大量内存。
答案 2 :(得分:1)
这是我的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