ruby-on-rails – 即使重新启动,我如何保持乘客独立?

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – 即使重新启动,我如何保持乘客独立?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_502_0@

我有几个应用程序在ruby 1.9.2上运行rails 3,并使用Nginx乘客部署在Ubuntu 10.04 LTS机器上.现在,我需要添加一个运行在ruby 1.8.7(REE)和Rails 2上的新应用程序.我完成了使用RVM,Passenger Standalone和一个反向代理.

问题是,每当我重新启动服务器(例如安装安全更新)时,我必须手动启动Passenger Standalone.

有办法自动启动吗?我被告知要使用Monit或God,但是我无法编写适合与Passenger Standalone合作的适当食谱.我也有上帝和RVM的一些问题,所以如果你有一个不使用神的解决方案,或者如果你知道如何正确地配置上帝/ Rvm,那就更好了.

最佳答案
这是我工作的使用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 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

和apache配置:

Upstart没有设置乘客所依赖的ENV [‘HOME],所以在执行乘客指挥时必须通过.除此之外,它挺直的.

调试注意事项:https://serverfault.com/questions/114052/logging-a-daemons-output-with-upstart(在脚本块中的第二行追加>> /tmp/upstart.log 2& 1)

希望这可以帮助.

原文链接:https://www.f2er.com/nginx/434574.html

猜你在找的Nginx相关文章