From 5d092797da3c07ffc2b514eff632616705e49616 Mon Sep 17 00:00:00 2001 From: Camden Narzt <6243207+CamJN@users.noreply.github.com> Date: Fri, 3 Jan 2025 13:27:24 -0700 Subject: [PATCH] add stop timeout option (#2578) --- 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 62641ae88a..6189a25e07 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,7 +1,8 @@ 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. * Fixes compilation with clang 19 (latest Fedora update) by dropping a buggy stddev function from the moving average header. Closes GH-2580. + * [Standalone] Adds a config option to specify the stop timeout for Passenger: `--stop-timeout 120` or `PASSENGER_STOP_TIMEOUT=120`. + * [Standalone] Changes Passenger's (not apps') start timeout to 25s (from 15s), stop timeouts default to 60s. * 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 eee204208b..405debddeb 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 5d9c26b6ee..5a38b6b71b 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 851182870f..884d7712f0 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 5b3cb3eb25..4b3ac74c19 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