【发布时间】:2015-08-24 16:50:23
【问题描述】:
我学习meteorjs,我有一个小型远程VPS。
我想要:
- 设置从我的流星项目的 git 存储库自动拉取。
- 将脚本放入自动启动,将我的流星项目作为服务运行。
例如
meteor run -p 80 -- production
我的服务器是 Ubuntu 12.04
【问题讨论】:
标签: git meteor ubuntu-12.04
我学习meteorjs,我有一个小型远程VPS。
我想要:
例如
meteor run -p 80 -- production
我的服务器是 Ubuntu 12.04
【问题讨论】:
标签: git meteor ubuntu-12.04
你应该使用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
【讨论】:
exec 节..
meteor 之前我们必须先cwd(这样我们就在项目目录中),可能必须使用`mrt.
这是我的工作:
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 以这种方式快速运行了一个流星应用程序,但节点似乎消耗了大量内存。
【讨论】:
这是我的 meteorjs.conf 文件 - 工作正常。 我之前已经描述过所有问题,但是这个变体修复了它们。 希望它可以帮助某人:)
我通过printenv得到的所有EXPORT变量
# 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
【讨论】:
exec meteor -p domain.com:8080 也必须更改为 chmod +x /etc/init/meteorjs.conf 并且效果很好:) Thx
env HOME=/home/sputnik 如果您不喜欢脚本中的脚本。