部署 部署 rails 使用 Passenger Standalone 如何重启

geekontheway · February 25, 2012 · Last by goodboyRyan replied at March 19, 2014 · 4650 hits

我的状况是 Passenger Standalone + Apache2[proxy,proxy-http]

所以

$cd  /var/rails/appname/current 
$passenger start -a 127.0.0.1 -p 3001 -d -e production

** [out] =============== Phusion Passenger Standalone web server started ===============
** [out] PID file: /var/rails/appname/releases/20120224113430/tmp/pids/passenger.3001.pid
** [out] Log file: /var/rails/appname/releases/20120224113430/log/passenger.3001.log
** [out] Environment: production
** [out] Accessible via: http://127.0.0.1:3001/
** [out] Serving in the background as a daemon.

在 deploy.rb 中


 task :start, :roles => :app do
        run "touch #{current_path}/tmp/restart.txt"
    end

desc "Restart Application"
    task :restart, :roles => :app do
        run "touch #{current_path}/tmp/restart.txt"
    end

每次部署后会发现线上的页面不是最新的 (passenger 没有成功重启),要上服务器手动重启,所以修改部署脚本:

desc "Restart Application"
task :restart, :roles => :app do

  run "cd #{previous_release}"
  run "appname_pid=$(cat tmp/pids/passenger.3001.pid)"
  run "kill $appname_pid"

  run "cd #{current_path}"
  run "passenger start -a 127.0.0.1 -p 3001 -d -e production"

会提示找不到文件passenger.3001.pid,指定一个 PID 文件位置 start/stop/restart 应该就可以了,还没尝试。不知道大家有没有更好的方法。

Anyway,过段时间可能要换 unicorn,应该会用 god 去监视 Passenger/unicorn

You need to Sign in before reply, if you don't have an account, please Sign up first.