我正在升级一个使用capistrano部署并运行puma的Rails应用程序,从ruby2.2.0/puma 3.2升级到ruby2.3.1/puma 3.4。当我部署的时候,puma似乎在错误的版本中重新启动。
在我部署之前,Puma在pid 4717 /版本3.4下运行
vagrant@vagrant-master:/mnt/code/shared/tmp/pids$ ps -ef | grep -i puma
vagrant 4717 1 0 20:53 ? 00:00:00 puma 3.4.0 (unix:///mnt/code/shared/tmp/sockets/code-puma.sock) [20160510205039]
vagrant 4720 4717 12 20:53 ? 00:00:10 puma: cluster worker 0: 4717 [20160510205039] 当我部署旧版本(puma 3.2 / Ruby 2.2.0)时,puma重新启动,它现在在pid 5466下运行:
vagrant@vagrant-master:/mnt/code/shared/tmp/pids$ ps -ef | grep -i puma
vagrant 5466 1 0 20:56 ? 00:00:00 puma 3.4.0 (unix:///mnt/code/shared/tmp/sockets/code-puma.sock) [20160510205440]
vagrant 6154 5466 0 20:56 ? 00:00:00 puma: cluster worker 0: 5466 [20160510205440] 我的puma错误日志显示它运行的是2.3.1而不是2.2.0
/usr/local/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.3/lib/bundler/spec_set.rb:95:
in `block in materialize': Could not find active_attr-0.8.5 in any of the sources (Bundler::GemNotFound)然而,它应该已经切换到Puma 3.2/ruby 2.2.0。当我强制终止美洲狮时,它会用正确的版本重启(通过monit) (本例中为美洲狮3.2 )
vagrant@vagrant-master:/mnt/code/shared/tmp/pids$ kill -9 5466
vagrant@vagrant-master:/mnt/code/shared/tmp/pids$ ps -ef | grep -i puma
vagrant 17834 1 0 21:04 ? 00:00:00 puma 3.2.0 (unix:///mnt/code/shared/tmp/sockets/code-puma.sock) [20160510205440]
vagrant 17837 17834 90 21:04 ? 00:00:01 puma: cluster worker 0: 17834 [20160510205440] 部署日志中的相关行:
DEBUG [07f95004] Running /usr/bin/env [ -f /mnt/code/shared/tmp/pids/puma.pid ] as vagrant@vagrant-master
DEBUG [07f95004] Command: [ -f /mnt/code/shared/tmp/pids/puma.pid ]
DEBUG [07f95004] Finished in 0.007 seconds with exit status 0 (successful).
DEBUG [42d98483] Running /usr/bin/env kill -0 $( cat /mnt/code/shared/tmp/pids/puma.pid ) as vagrant@vagrant-master
DEBUG [42d98483] Command: kill -0 $( cat /mnt/code/shared/tmp/pids/puma.pid )
DEBUG [42d98483] Finished in 0.007 seconds with exit status 0 (successful).
INFO [e81875a3] Running RBENV_ROOT=/usr/local/rbenv RBENV_VERSION=2.2.0 /usr/local/rbenv/bin/rbenv exec bundle exec pumactl -S /mnt/code/shared/tmp/pids/puma.state restart as vagrant@vagrant-master
DEBUG [e81875a3] Command: cd /mnt/code/current && ( export PATH="/usr/local/rbenv/shims:/usr/local/rbenv/bin:$PATH" RBENV_ROOT="/usr/local/rbenv" RBENV_VERSION="2.2.0" RACK_ENV="vagrant" ; RBENV_ROOT=/usr/local/rbenv RBENV_VERSION=2.2.0 /usr/local/rbenv/bin/rbenv exec bundle exec pumactl -S /mnt/code/shared/tmp/pids/puma.state restart )
DEBUG [e81875a3] Command restart sent success这是我在capistrano中的puma配置的一部分
set :puma_bind, "unix://#{shared_path}/tmp/sockets/#{fetch(:application)}-puma.sock"
set :puma_state, "#{shared_path}/tmp/pids/puma.state"
set :puma_pid, "#{shared_path}/tmp/pids/puma.pid"
set :puma_preload_app, false
set :puma_prune_bundler, true如何在不终止puma进程的情况下部署ruby版本和puma版本的更改?为什么puma从错误的版本开始?
谢谢
发布于 2016-05-18 04:05:46
检查puma.rb配置文件是否指定了puma.pid和puma.state路径:
pidfile '/mnt/code/shared/tmp/pids/puma.pid'
state_path '/mnt/code/shared/tmp/pids/puma.state'还要检查deploy/production.rb是否指定了指向以下位置的路径:
set :puma_state, "#{shared_path}/tmp/pids/puma.state"
set :puma_pid, "#{shared_path}/tmp/pids/puma.pid"我也有类似的问题,在设置了这个之后,它工作得很好。
https://stackoverflow.com/questions/37149047
复制相似问题