使用capistrano在生产中运行rpush作为守护进程

时间:2015-03-11 07:59:46

标签: ruby-on-rails push-notification capistrano

我已经设置了我的rails应用程序以与rpush一起使用。它使用rpush start在开发中本地工作正常。但现在我想使用capistrano- 2.15.5 将其部署到我的EC2服务器。

deploy.rb的一部分:

after "deploy:stop",    "delayed_job:stop"
after "deploy:stop",    "rpush:stop"

after "deploy:start",   "delayed_job:start"
after "deploy:start",   "rpush:start"

after "deploy:restart", "delayed_job:restart"
after "deploy:restart", "rpush:restart"

namespace :rpush do
  %w[start stop restart].each do |command|
    desc "#{command} rpush deamon"
    task command, roles: :app, except: {no_release: true} do
      run "cd #{deploy_to}/current && bundle exec rpush #{command}"
    end
  end
end

现在,问题

  • 它始于开发环境。我试图理解this页面告诉我该怎么做,但我做不到。
  • 我不知道pid是否存储在/current目录或/shared目录中。它应该在共享中,以便文件在部署之间持续存在

如果有人这样做(即使是以不同的方式),请告诉我如何做。

或者,我如何修复我的上限配方和/initializers/rpush

1 个答案:

答案 0 :(得分:7)

对于Capistrano 3:

after :finished, :restart_rpush do
  on roles(:web) do
    within release_path do
      with rails_env: fetch(:rails_env) do
        execute :bundle, :exec, "rpush stop -e #{fetch(:rails_env)}"
        execute :bundle, :exec, "rpush start -e #{fetch(:rails_env)}"
      end
    end
  end
end

然后检查tmp和其他目录是否正确链接:

set :linked_dirs, %w{log tmp/pids tmp/cache tmp/sockets vendor/bundle public/uploads}