1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00

add additional env when start rails, such as : secret key, db username, db pwd or other what you want

This commit is contained in:
Robot Jiang 2015-06-20 09:11:32 +08:00
parent 75fa5fd2fd
commit b2f604cc64

View file

@ -22,7 +22,7 @@ Capistrano::Configuration.instance.load do
namespace :puma do namespace :puma do
desc 'Start puma' desc 'Start puma'
task :start, :roles => lambda { puma_role }, :on_no_matching_servers => :continue do task :start, :roles => lambda { puma_role }, :on_no_matching_servers => :continue do
run "cd #{current_path} && #{puma_cmd} #{start_options}", :pty => false run "cd #{current_path} && #{deploy_additional_env} #{puma_cmd} #{start_options}", :pty => false
end end
desc 'Stop puma' desc 'Stop puma'
@ -33,7 +33,7 @@ Capistrano::Configuration.instance.load do
desc 'Restart puma' desc 'Restart puma'
task :restart, :roles => lambda { puma_role }, :on_no_matching_servers => :continue do task :restart, :roles => lambda { puma_role }, :on_no_matching_servers => :continue do
begin begin
run "cd #{current_path} && #{pumactl_cmd} -S #{state_path} restart" run "cd #{current_path} && #{deploy_additional_env} #{pumactl_cmd} -S #{state_path} restart"
rescue Capistrano::CommandError => ex rescue Capistrano::CommandError => ex
puts "Failed to restart puma: #{ex}\nAssuming not started." puts "Failed to restart puma: #{ex}\nAssuming not started."
start start
@ -43,7 +43,7 @@ Capistrano::Configuration.instance.load do
desc 'Restart puma (phased restart)' desc 'Restart puma (phased restart)'
task :phased_restart, :roles => lambda { puma_role }, :on_no_matching_servers => :continue do task :phased_restart, :roles => lambda { puma_role }, :on_no_matching_servers => :continue do
begin begin
run "cd #{current_path} && #{pumactl_cmd} -S #{state_path} phased-restart" run "cd #{current_path} && #{deploy_additional_env} #{pumactl_cmd} -S #{state_path} phased-restart"
rescue Capistrano::CommandError => ex rescue Capistrano::CommandError => ex
puts "Failed to restart puma: #{ex}\nAssuming not started." puts "Failed to restart puma: #{ex}\nAssuming not started."
start start
@ -72,6 +72,11 @@ Capistrano::Configuration.instance.load do
fetch(:rack_env, fetch(:rails_env, 'production')) fetch(:rack_env, fetch(:rails_env, 'production'))
end end
#add additional env when start rails, such as : secret key, db username, db pwd or other what you want.
def deploy_additional_env
fetch(:deploy_additional_env, '')
end
def state_path def state_path
(config_file ? configuration.options[:state] : nil) || puma_state (config_file ? configuration.options[:state] : nil) || puma_state
end end