Pab*_* B. 9 ruby-on-rails passenger nginx god monit
我有几个应用程序在ruby 1.9.2上运行rails 3并使用nginx + passenger部署在Ubuntu 10.04 LTS机器上.现在,我需要添加一个在ruby 1.8.7(REE)和Rails 2上运行的新应用程序.我完成了使用RVM,Passenger Standalone和反向代理.
问题是,每次我必须重新启动服务器(例如安装安全更新)时,我必须手动启动Passenger Standalone.
有没有办法自动启动它?我被告知要使用Monit或God,但我无法编写适用于Passenger Standalone的正确配方.我也有上帝和RVM的一些问题,所以如果你有一个不使用上帝的解决方案,或者如果你知道如何正确配置God/Rvm,那就更好了.
jva*_*tic 15
这就是我的工作.使用Upstart(Ubuntu 10.04)启动乘客守护程序
我的环境使用rvm和ruby 1.9.2以及apache和我的rails应用程序通过capistrano部署
# Upstart: /etc/init/service_name.conf
description "start passenger stand-alone"
author "Me <me@myself.am>"
# Stanzas
#
# Stanzas control when and how a process is started and stopped
# See a list of stanzas here: http://upstart.ubuntu.com/wiki/Stanzas#respawn
# When to start the service
start on started mysql
# 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
end script
# Start the process
script
cd /var/path/to/app/staging/current
sh HOME=/home/deploy /usr/local/rvm/gems/ruby-1.9.2-p136@appname/gems/passenger-3.0.7/bin/passenger start --user 'deploy' -p '5000' -a '127.0.0.1' -e 'production'
end script
Run Code Online (Sandbox Code Playgroud)
和apache配置:
<VirtualHost *:80>
ServerName myapp.com
PassengerEnabled off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://127.0.0.1:5000/
ProxyPassReverse / http://127.0.0.1:5000/
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
Upstart没有设置乘客所依赖的ENV ['HOME'],所以我们必须在执行乘客命令时传递它.除此之外它非常直接.
调试说明:https://serverfault.com/questions/114052/logging-a-daemons-output-with-upstart(附加>> /tmp/upstart.log 2>&1到脚本块中的第二行)
希望这可以帮助.
| 归档时间: |
|
| 查看次数: |
5243 次 |
| 最近记录: |