ec2_roles :name => :apiserver,
:options => {:default=>true} ,
:variables => {
:domain => "apiserver.dev.instamotor.com",
:thin_server_tag => "apiserver",
:rackup_path => "apiserver/config.ru"
}
ec2_roles :name => :telegraph,
:options => {:default=>true} ,
:variables => {
:domain => "telegraph.dev.instamotor.com",
:thin_server_tag => "telegraph",
:rackup_path => "telegraph/config.ru"
}
task :restart_apiserver, :roles => [:apiserver], :on_no_matching_servers => :continue do
thin_config_path = "#{current_path}/config/server/thin.#{domain}.yml"
thin_rackup_path = "#{current_path}/#{rackup_path}"
restart_thin = "cd #{current_path} && bundle exec thin -C #{thin_config_path} -R #{thin_rackup_path} restart >> #{current_path}/log/#{thin_server_tag}.thin.log 2>&1"
restart_nginx = "sudo service nginx restart"
run "#{restart_thin}"
run "#{restart_nginx}"
end
task :restart_telegraph, :roles => [:telegraph] , :on_no_matching_servers => :continue do
thin_config_path = "#{current_path}/config/server/thin.#{domain}.yml"
thin_rackup_path = "#{current_path}/#{rackup_path}"
restart_thin = "cd #{current_path} && bundle exec thin -C #{thin_config_path} -R #{thin_rackup_path} restart >> #{current_path}/log/#{thin_server_tag}.thin.log 2>&1"
restart_nginx = "sudo service nginx restart"
run "#{restart_thin}"
run "#{restart_nginx}"
end
cap integration telegraph apiserver deploy:restart
Only the apiserver variables get set in both the telegraph task and the apiserver task so both tasks end up calling the command
"cd /home/ubuntu/current && bundle exec thin -C /home/ubuntu/current/config/server/thin.apiserver.dev.instamotor.com.yml -R /home/ubuntu/current/apiserver/config.ru restart >> /home/ubuntu/current/log/apiserver.thin.log 2>&1"