2013-11-22 35 views
0

目前運行Capistrano的部署:Capistrano的。因爲沒有服務器.... puma.state停止

環境: Capistrano 2.15.5

RAILS_ENV=uat cap deploy

2013-11-22 04:27:34 executing `puma:stop' 
* no servers for "cd /home/ubuntu/fancied-server/current; bundle exec pumactl -S /home/ubuntu/fancied-server/shared/sockets/puma.state stop" 

我Capistrano的:

require "capistrano" 

set :rvm_ruby_string, :local   # use the same ruby as used locally for deployment 
set :rvm_autolibs_flag, "read-only"  # more info: rvm help autolibs 

before 'deploy:setup', 'rvm:install_rvm' # install RVM 
before 'deploy:setup', 'rvm:install_ruby' # install Ruby and create gemset, OR: 

if ENV['RAILS_ENV'] == 'uat' 
    # The address of the remote host on EC2 (the Public DNS address) 
    set :location, "54.252.151.190" 
    set :branch, "uat" 
    role :app, location 
    role :web, location 
    role :db, location, :primary => true 
    role :resque, location 
    role :rapns, location 

    #after 'deploy:stop', 'puma:stop' 
    #after 'deploy:start', 'puma:start' 
    #after 'deploy:restart', 'puma:restart' 

    # Ensure the tmp/sockets directory is created by the deploy:setup task and 
    # symlinked in by the deploy:update task. This is not handled by Capistrano 
    # v2 but is fixed in v3. 
    #shared_children.push('tmp/sockets') 

    _cset(:puma_cmd) { "#{fetch(:bundle_cmd, 'bundle')} exec puma" } 
    _cset(:pumactl_cmd) { "#{fetch(:bundle_cmd, 'bundle')} exec pumactl" } 
    _cset(:puma_state) { "#{shared_path}/sockets/puma.state" } 
    _cset(:puma_socket) { "unix://#{shared_path}/sockets/puma.sock" } 
    _cset(:puma_role) { :app } 
end 

namespace :deploy do 
    task :start, :roles => :web, :on_error => :continue do 
    if ENV['RAILS_ENV'] == 'uat' 
     if !puma.puma_pid_exists? 
     puma.start 
     else 
     puma.restart 
     end 
    else 
     run start_command 
    end 
    sleep 2 
    warmup_cache 
    end 
.... 


namespace :puma do 
    desc 'Start puma' 
    task :start, :roles => lambda { fetch(:puma_role) }, :on_no_matching_servers => :continue, :on_error => :continue do 
    run "cd #{current_path} && #{fetch(:puma_cmd)} #{start_options}", :pty => false 
    end 

    desc 'Stop puma' 
    task :stop, :roles => lambda { fetch(:puma_role) }, :on_no_matching_servers => :continue, :on_error => :continue do 
    run "cd #{current_path}; #{fetch(:pumactl_cmd)} -S #{state_path} stop" 
    end 

    desc 'Restart puma' 
    task :restart, :roles => lambda { fetch(:puma_role) }, :on_no_matching_servers => :continue, :on_error => :continue do 
    run "cd #{current_path}; #{fetch(:pumactl_cmd)} -S #{state_path} restart" 
    end 
end 

所以問題是:我服務器設置正確嗎?或者如何設置服務器,所以它會停止對問題的糾正

回答

0

我現在沒有辦法測試它,但是您是否嘗試過移動if塊之外的服務器位置和角色?

在部署之前(至少第一次),它總是一個很好的做法來做一個帽子部署:檢查。它會檢查是否滿足基本依賴關係,比如擁有正確的權限,檢查是否安裝了svn/git等。

對於多級部署,Capistrano實際上提供了一種更簡潔的方式來定義角色,服務器和其他環境特定的配置首先在config/deploy.rb中定義角色,然後在config/deploy/.rb( - 環境)下具有特定於環境的配置文件。 舉個例子,你可以用這種方式定義在配置/ deploy.rb階段:

set :stages, %w(production staging) 
set :default_stage, "staging" 

然後你可以定義環境的具體配置,在自己的配置文件。例如,在配置/部署/ production.rb:

set :rails_env, 'production' 

namespace :deploy do 
    task :start do 
    # ... 
    end 

    task :stop do 
    # ... 
    end 

    task :restart do 
    # ... 
    end 
end 

來源:https://github.com/capistrano/capistrano/wiki/2.x-Multistage-Extension