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

running rpush as daemon in production using 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

现在,问题

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

或者,我怎样才能修复我的上限配方和/initializers/rpush

对于 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}