将Sidekiq升级到v6后,它不会自动开始生产

这是Capistrano的输出:

02:05 sidekiq:start
      01 sudo service sidekiq start index=1
      01 sidekiq (1) start/running,process 26392
    ✔ 01 deployer@IP 0.721s
      02 sudo service sidekiq start index=2
      02 sidekiq (2) start/running,process 26505
    ✔ 02 deployer@IP 0.728s

登录到服务器和ps aux | grep sidekiq后,没有任何进程在运行。所以我回到本地终端标签并运行

cap staging sidekiq:start

新的Sidekiq进程在服务器上显示了几秒钟:

ps aux | grep sidekiq
deployer   489 52.0  1.0  76344 40856 ?        Rs   13:13   0:00 /home/deployer/.rvm/rubies/ruby-2.6.3/bin/ruby /home/deployer/.rvm/gems/ruby-2.6.3/bin/bundle exec sidekiq -i 1 -e staging
deployer   695  0.0  0.0  10472   936 pts/0    S+   13:13   0:00 grep --color=auto sidekiq
deployer 32744 42.2  1.4 111100 56188 ?        Rs   13:13   0:02 /home/deployer/apps/app-staging/shared/bundle/ruby/2.6.0/bin/sidekiq -i 2 -e staging

但是几秒钟后,它会消失。

如果我从服务器RAILS_ENV=staging bundle exec sidekiq运行-Sidekiq正在运行。但是第二次我重新启动服务器/部署新代码后,Sidekiq进程被杀死。

这是我对Sidekiq的耙任务:

namespace :sidekiq do
  desc "Tells Sidekiq (with signal TSTP) it will be shutting down at some point in the near future."\
  " It will stop accepting new work but continue working on current messages"
  task :quiet do
    on roles(:app) do
      puts capture("pgrep -f 'sidekiq' | xargs kill -TSTP")
    end
  end

  desc "Signals that Sidekiq should shut down within the -t timeout option given at start-up (see config/sidekiq.yml)."\
  " It will stop accepting new work,but continue working on current messages (as with USR1)."\
  " Any workers that do not finish within the timeout are forcefully terminated"\
  " and their messages are pushed back to Redis to be executed again when Sidekiq starts up. "
  task :terminate_gracefully do
    on roles(:app) do
      puts capture("pgrep -f 'sidekiq' | xargs kill -TERM")
    end
  end


  desc "Starts sidekiq workers. Fails if there are already running processes."
  task :start do
    on roles(:app) do
      pids =  capture("pgrep -f 'sidekiq'; true")
      puts "Present sidekiq process pids #{pids}"
      if pids.split("\n").count == 1
        # For each worker service with index ID is called
        execute "sudo service sidekiq start index=1"
        execute "sudo service sidekiq start index=2"
      else
        puts "##------------------------------------------------------------------##"
        puts "Sidekiq was not terminated before start execution. Wait untils it is finished and start it again (or kill the processes)."
        puts "##------------------------------------------------------------------##"
      end
    end
  end

  task :restart do
    invoke "sidekiq:terminate_gracefully"
    invoke "sidekiq:start"
  end
end

为什么Capistrano无法自动启动Sidekiq v6?

smallantji 回答:将Sidekiq升级到v6后,它不会自动开始生产

Sidekiq 6.0不再依赖于守护进程,请参阅重大更改: https://github.com/mperham/sidekiq/blob/master/Changes.md#60

BREAKING CHANGE删除守护进程,日志文件和pidfile Sidekiq的参数。使用适当的流程主管(例如systemd或 工头)管理Sidekiq。请参阅“部署” Wiki页面,以获取指向的链接。 更多资源。

查看本主题如何使用sidekiq 6.0正确设置systemd: https://github.com/seuros/capistrano-sidekiq/issues/224

或官方Wiki: https://github.com/mperham/sidekiq/wiki/Deployment#running-your-own-process

,

在6.0 sidekiq removed daemonization support中,许多初始化脚本和capistrano示例都使用了它。这样做是为了敦促人们使用适当的流程管理器(例如systemd),该管理器具有很多稳定性和可管理性。

您应该相应地修改部署(实际上,许多项目并未注意到此更改,因为较旧的版本也更好地以这种方式运行)。有关如何设置部署的信息,请参见official wiki

本文链接:https://www.f2er.com/2590060.html

大家都在问