首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Rails+Capistrano:部署新代码时,Sidekiq并不总是启动

Rails+Capistrano:部署新代码时,Sidekiq并不总是启动
EN

Stack Overflow用户
提问于 2016-04-25 15:29:43
回答 1查看 1.7K关注 0票数 1

我有时在部署使用Capistrano的新代码时遇到Sidekiq问题。

这是我的设置(deploy/production.rb):

代码语言:javascript
复制
set :rails_env, "production"
set :stage, :production

set :whenever_command, "bundle exec whenever"
set :whenever_environment, defer { stage }
require "whenever/capistrano"

set :user, 'deployer'
set :use_sudo, false

before "deploy", "deploy:setup"
after "deploy:restart", "deploy:cleanup"

server "IP", :web, :app, :db, primary: true
set :deploy_to, "/home/deployer/apps/myapp-production/"

set :ssh_options, { :forward_agent => true }
set :keep_releases, 3

namespace :deploy do
  %w[start stop restart].each do |command|
    desc "#{command} unicorn server"
    task command, roles: :app, except: {no_release: true} do
      run "/etc/init.d/unicorn_myapp-production #{command}"
    end
  end
  task :setup_config, roles: [:app] do
    sudo "ln -nfs #{current_path}/config/nginx_production.conf /etc/nginx/sites-enabled/default"
    sudo "ln -nfs #{current_path}/config/unicorn_init_production.sh /etc/init.d/unicorn_myapp-production"
    run "mkdir -p #{shared_path}/config"
    put File.read("config/database.yml"), "#{shared_path}/config/database.yml"
    puts "Now edit the config files in #{shared_path}."
  end
  after "deploy:setup", "deploy:setup_config"

  task :symlink_config, roles: [:app] do
    run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
  end
  after "deploy:finalize_update", "deploy:symlink_config"
  after "deploy:create_symlink", "deploy:restart"

  desc "Make sure local git is in sync with remote."
  task :check_revision, roles: [:web] do
    unless `git rev-parse HEAD` == `git rev-parse origin/master`
      puts "WARNING: HEAD is not the same as origin/master"
      puts "Run `git push` to sync changes."
      exit
    end
  end

  namespace :assets do
    task :precompile, :roles => :web, :except => { :no_release => true } do
      begin
        from = source.next_revision(current_revision) # <-- Fail here at first-time deploy because of current/REVISION absence
      rescue
        err_no = true
      end
      if err_no || capture("cd #{latest_release} && #{source.local.log(from)} vendor/assets/ app/assets/ | wc -l").to_i > 0
        run %Q{cd #{latest_release} && #{rake} RAILS_ENV=#{rails_env} #{asset_env} assets:precompile}
      else
        logger.info "Skipping asset pre-compilation because there were no asset changes"
      end
    end
  end

  before "deploy", "deploy:check_revision"
end

有时会发生的情况是,我部署了一些代码,一次Sidekiq运行,另一次没有运行。我要说的是,1/5的情况下,Sidekiq在部署新代码后没有运行(未重新启动)。

如何确保Sidekiq在每次部署后始终运行(正确重新启动)?

谢谢

编辑:

deploy.rb

代码语言:javascript
复制
require "capistrano/ext/multistage"
require "rvm/capistrano"
require 'bundler/capistrano'
require 'delayed/recipes' # added for running deplayed jobs
require 'capistrano/sidekiq'

set :application, 'myapp'
set :bundle_flags, "--quiet --no-cache"

# Default value for :scm is :git
set :scm, :git
default_run_options[:pty] = true
set :deploy_via, :remote_cache
set :repository, 'git@bitbucket.org:username/myapp.git'
set :branch, "master"

set :normalize_asset_timestamps, false

set :pty, true

EDIT2:,我也不确定这是否相关,但有时当我在/config文件夹中更改某些内容时,我需要登录到(Ubuntu)服务器,终止独角兽进程并手动启动服务器以查看更改。

EN

回答 1

Stack Overflow用户

发布于 2019-01-28 12:01:40

这是一个已知的问题与卡皮斯特拉诺3,设置pty为false应该解决问题。

有一个已知的bug,防止了当pty在Capistrano 3上为真时就无法启动。 一组:pty,假

https://github.com/seuros/capistrano-sidekiq#known-issues-with-capistrano-3

相关问题:https://github.com/seuros/capistrano-sidekiq/issues/23

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36844927

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档