目前正在运行capistrano进行部署:
环境:
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 :(得分:0)
我现在没有办法测试它,但您是否尝试将服务器位置和角色移到if块之外。
在部署之前(至少是第一次),执行上限部署始终是一个好习惯:检查。它将检查是否满足基本依赖关系,例如是否具有正确的权限,检查是否安装了svn / git等。
对于多阶段部署,Capistrano实际上提供了一种更清晰的方式来定义角色,服务器和其他特定于环境的配置,首先在config / deploy.rb中定义角色,然后在config / deploy / .rb( - 环境)。 作为示例,您可以通过以下方式在config / deploy.rb上定义阶段:
set :stages, %w(production staging)
set :default_stage, "staging"
然后您可以在自己的配置文件中定义特定于环境的配置。例如,在config / deploy / 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