2015-08-13 22 views
4

我想通过Capistrano与Puma和Nginx部署我的rails。我为Puma配置了deploy.rb,并在gem文件中添加了所需的gem。没有这样的文件或目录 - 连接(2)“/ tmp/puma-status-1439451994589-14316”

我能够运行初始部署命令作为'cap production deploy:initial'并且能够访问我的rails应用程序,如下所述。

但是,当我想部署一些新的更改或重新启动美洲狮它失败,并给出了这个错误。

的Gemfile:

gem 'capistrano', '~> 3.4.0' 
gem 'capistrano-rvm',  require: false 
gem 'capistrano-rails', require: false 
gem 'capistrano-bundler', require: false 
gem 'capistrano3-puma', require: false 
# gem 'capistrano-passenger', require: false 
gem 'capistrano-ext',  require: false 
gem 'capistrano-faster-assets', '~> 1.0.2' 

Capfile:

# Load DSL and set up stages 
require 'capistrano/setup' 

# Include default deployment tasks 
require 'capistrano/deploy' 
require 'capistrano/rails' 
require 'capistrano/bundler' 
require 'capistrano/rails/assets' 
require 'capistrano/rails/migrations' 
require 'capistrano/faster_assets' 

require 'capistrano/rvm' 
require 'capistrano/puma' 
require 'capistrano/puma/workers' 
require 'capistrano/puma/nginx' 
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r } 

deploy.rb

# Puma Server Configuration 
set :puma_threads, [4, 16] 
set :puma_workers, 1 

# Don't change these unless you know what you're doing 
set :pty,    true 
set :use_sudo,  false 
set :puma_bind,  "unix://#{shared_path}/tmp/sockets/puma.sock" 
# set :puma_conf,  "#{shared_path}/puma.rb" 
set :puma_state,  "#{shared_path}/tmp/pids/puma.state" 
set :puma_pid,  "#{shared_path}/tmp/pids/puma.pid" 
set :puma_access_log, "#{release_path}/log/puma.error.log" 
set :puma_error_log, "#{release_path}/log/puma.access.log" 
set :puma_preload_app, true 
set :puma_worker_timeout, nil 
set :puma_init_active_record, true 

namespace :puma do 
    desc 'Create Directories for Puma Pids and Socket' 
    task :make_dirs do 
    on roles(:app) do 
     execute "mkdir #{shared_path}/tmp/sockets -p" 
     execute "mkdir #{shared_path}/tmp/pids -p" 
    end 
    end 

    before :start, :make_dirs 
end 

namespace :deploy do 
    desc "Make sure local git is in sync with remote." 
    task :check_revision do 
    on roles(:app) do 
     unless `git rev-parse HEAD` == `git rev-parse origin/capistrano` 
     puts "WARNING: HEAD is not the same as origin/capistrano" 
     puts "Run `git push` to sync changes." 
     exit 
     end 
    end 
    end 

    desc 'Initial Deploy' 
    task :initial do 
    on roles(:app) do 
     before 'deploy:restart', 'puma:start' 
     invoke 'deploy' 
    end 
    end 

    desc 'Restart application' 
    task :restart do 
    on roles(:app), in: :sequence, wait: 5 do 
     invoke 'puma:restart' 
    end 
    end 

    before :starting,  :check_revision 
    after :finishing, :compile_assets 
    after :finishing, :cleanup 
    after :finishing, :restart 
end 

我也用的是低命令为Puma和Nginx生成模板,如下所示。

rails g capistrano:nginx_puma:config 

我在下面运行命令来部署我的导轨EC2实例(与Ubuntu)

cap production deploy:check 
cap production puma:config 
cap production puma:nginx_config 
cap production deploy:initial 

现在,我要部署一些变化与下面的代码。

cap production deploy 

但我得到的错误如下。

(Backtrace restricted to imported tasks) 
cap aborted! 
SSHKit::Runner::ExecuteError: Exception while executing as [email protected]: bundle exit status: 1 
bundle stdout: No such file or directory - connect(2) for "/tmp/puma-status-1439451994589-14316" 
bundle stderr: Nothing written 

SSHKit::Command::Failed: bundle exit status: 1 
bundle stdout: No such file or directory - connect(2) for "/tmp/puma-status-1439451994589-14316" 
bundle stderr: Nothing written 

Tasks: TOP => deploy:restart 
(See full trace by running task with --trace) 

请帮忙! 谢谢

回答

0

我找到了解决此问题的一种解决方法。 只需将以下代码段添加到您的deploy.rb文件中即可。 它将重写美洲狮重启任务。

Rake::Task["puma:restart"].clear_actions 

namespace :puma do 
    task :restart do 
    on roles(:all) do 
     execute "RACK_ENV=#{fetch(:rails_env)} #{fetch(:rvm_binary)} #{fetch(:rvm_ruby_version)} do pumactl -S #{shared_path}/tmp/pids/puma.state restart" 
    end 
    end 
end 
+0

好的,谢谢,我会试试:) –

相关问题