これが私が働いたものです。Upstart(Ubuntu 10.04)を使用してパッセンジャーデーモンを起動する
私の環境はruby1.9.2とapacheを備えたrvmを使用しており、私の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
および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>
Upstartは、passengerが依存するENV ['HOME']を設定しないため、passengerコマンドを実行するときにそれを渡す必要があります。それ以外はかなり簡単です。
デバッグに関する注意:https>> /tmp/upstart.log 2>&1
://serverfault.com/questions/114052/logging-a-daemons-output-with-upstart(スクリプトブロックの2行目に次のようなものを追加してください)
お役に立てれば。