diff --git a/lib/puma/capistrano.rb b/lib/puma/capistrano.rb index fbe01c03..dcbe92bc 100644 --- a/lib/puma/capistrano.rb +++ b/lib/puma/capistrano.rb @@ -22,7 +22,7 @@ Capistrano::Configuration.instance.load do namespace :puma do desc 'Start puma' 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 desc 'Stop puma' @@ -33,7 +33,7 @@ Capistrano::Configuration.instance.load do desc 'Restart puma' task :restart, :roles => lambda { puma_role }, :on_no_matching_servers => :continue do 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 puts "Failed to restart puma: #{ex}\nAssuming not started." start @@ -43,7 +43,7 @@ Capistrano::Configuration.instance.load do desc 'Restart puma (phased restart)' task :phased_restart, :roles => lambda { puma_role }, :on_no_matching_servers => :continue do 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 puts "Failed to restart puma: #{ex}\nAssuming not started." start @@ -72,6 +72,11 @@ Capistrano::Configuration.instance.load do fetch(:rack_env, fetch(:rails_env, 'production')) 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 (config_file ? configuration.options[:state] : nil) || puma_state end