From 657aff2a8882a476d92d706755dd04cc2c21b461 Mon Sep 17 00:00:00 2001 From: Camden Narzt Date: Fri, 13 Dec 2024 13:26:35 -0700 Subject: [PATCH] add stop timeout option --- CHANGELOG | 3 ++- .../phusion_passenger/standalone/config_options_list.rb | 8 +++++++- .../standalone/start_command/builtin_engine.rb | 3 ++- .../standalone/start_command/nginx_engine.rb | 2 +- .../phusion_passenger/standalone/stop_command.rb | 8 +++++++- 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 6016cf0450..aaa991a545 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ Release 6.0.25 (Not yet released) ------------- - * [Standalone] Changes Passenger (not app) start and stop timeouts to 25s (from 15s) except for Nginx engine mode, which retains a stop timeout of 60s. + * [Standalone] Changes Passenger's (not apps') start timeout to 25s (from 15s), stop timeouts default to 60s. + * [Standalone] Adds a config option to specify the stop timeout for Passenger: `--stop-timeout 120` or `PASSENGER_STOP_TIMEOUT=120`. * diff --git a/src/ruby_supportlib/phusion_passenger/standalone/config_options_list.rb b/src/ruby_supportlib/phusion_passenger/standalone/config_options_list.rb index a76bfcf721..eb43e4b5d3 100644 --- a/src/ruby_supportlib/phusion_passenger/standalone/config_options_list.rb +++ b/src/ruby_supportlib/phusion_passenger/standalone/config_options_list.rb @@ -165,6 +165,12 @@ module Standalone :type => :path, :desc => 'Where to store the PID file' }, + { + :name => :stop_timeout, + :type => :integer, + :default => 60, + :desc => "How long in seconds to wait for the HTTP engine to gracefully shutdown,\nbefore killing it.\nDefault: %DEFAULT%" + }, { :name => :instance_registry_dir, :type => :path, @@ -263,7 +269,7 @@ module Standalone :type => :hostname, :type_desc => 'HOST', :default => '127.0.0.1', - :desc => "The address that Passenger binds to in order to allow sending HTTP requests to individual application processes.\nDefault: %DEFAULT%" + :desc => "The address that Passenger binds to in order to allow sending\nHTTP requests to individual application processes.\nDefault: %DEFAULT%" }, { :name => :static_files_dir, diff --git a/src/ruby_supportlib/phusion_passenger/standalone/start_command/builtin_engine.rb b/src/ruby_supportlib/phusion_passenger/standalone/start_command/builtin_engine.rb index 26ab11f3ac..4b6e9b3813 100644 --- a/src/ruby_supportlib/phusion_passenger/standalone/start_command/builtin_engine.rb +++ b/src/ruby_supportlib/phusion_passenger/standalone/start_command/builtin_engine.rb @@ -200,7 +200,8 @@ def build_daemon_controller_options :ping_command => ping_spec, :pid_file => @options[:pid_file], :log_file => @options[:log_file], - :start_timeout => 25 + :start_timeout => 25, + :stop_timeout => @options[:stop_timeout] } end diff --git a/src/ruby_supportlib/phusion_passenger/standalone/start_command/nginx_engine.rb b/src/ruby_supportlib/phusion_passenger/standalone/start_command/nginx_engine.rb index 4b437be473..44faa74cfb 100644 --- a/src/ruby_supportlib/phusion_passenger/standalone/start_command/nginx_engine.rb +++ b/src/ruby_supportlib/phusion_passenger/standalone/start_command/nginx_engine.rb @@ -166,7 +166,7 @@ def build_daemon_controller_options :pid_file => @options[:pid_file], :log_file => @options[:log_file], :start_timeout => 25, - :stop_timeout => 60, + :stop_timeout => @options[:stop_timeout], :log_file_activity_timeout => 12, :dont_stop_if_pid_file_invalid => true } diff --git a/src/ruby_supportlib/phusion_passenger/standalone/stop_command.rb b/src/ruby_supportlib/phusion_passenger/standalone/stop_command.rb index c632cdbba8..fb95fc7029 100644 --- a/src/ruby_supportlib/phusion_passenger/standalone/stop_command.rb +++ b/src/ruby_supportlib/phusion_passenger/standalone/stop_command.rb @@ -84,6 +84,12 @@ def self.create_option_parser(options) "Don't abort with an error if PID file cannot be found") do options[:ignore_pid_not_found] = true end + opts.on("-t", "--timeout NUMBER", Integer, + "How long in seconds to wait for the HTTP engine to#{nl}"+ + "gracefully shutdown, before killing it.#{nl}" + + "Default: #{defaults[:stop_timeout]}") do |value| + options[:stop_timeout] = value + end end end @@ -125,7 +131,7 @@ def create_controller :ping_command => "true", # Doesn't matter :pid_file => @options[:pid_file], :log_file => "/dev/null", - :stop_timeout => 25 + :stop_timeout => @options[:stop_timeout] ) end end