diff --git a/functions-common b/functions-common index 283a6cf3d5..120d3782ac 100644 --- a/functions-common +++ b/functions-common @@ -1395,6 +1395,8 @@ function write_user_unit_file { iniset -sudo $unitfile "Unit" "Description" "Devstack $service" iniset -sudo $unitfile "Service" "User" "$user" iniset -sudo $unitfile "Service" "ExecStart" "$command" + iniset -sudo $unitfile "Service" "KillMode" "process" + iniset -sudo $unitfile "Service" "TimeoutStopSec" "infinity" if [[ -n "$group" ]]; then iniset -sudo $unitfile "Service" "Group" "$group" fi @@ -1417,7 +1419,7 @@ function write_uwsgi_user_unit_file { iniset -sudo $unitfile "Service" "User" "$user" iniset -sudo $unitfile "Service" "ExecStart" "$command" iniset -sudo $unitfile "Service" "Type" "notify" - iniset -sudo $unitfile "Service" "KillSignal" "SIGQUIT" + iniset -sudo $unitfile "Service" "KillMode" "process" iniset -sudo $unitfile "Service" "Restart" "always" iniset -sudo $unitfile "Service" "NotifyAccess" "all" iniset -sudo $unitfile "Service" "RestartForceExitStatus" "100" diff --git a/lib/apache b/lib/apache index dfca25a764..39d5b7b071 100644 --- a/lib/apache +++ b/lib/apache @@ -260,10 +260,15 @@ function write_uwsgi_config { # Set die-on-term & exit-on-reload so that uwsgi shuts down iniset "$file" uwsgi die-on-term true iniset "$file" uwsgi exit-on-reload true + # Set worker-reload-mercy so that worker will not exit till the time + # configured after graceful shutdown + iniset "$file" uwsgi worker-reload-mercy $WORKER_TIMEOUT iniset "$file" uwsgi enable-threads true iniset "$file" uwsgi plugins python # uwsgi recommends this to prevent thundering herd on accept. iniset "$file" uwsgi thunder-lock true + # Set hook to trigger graceful shutdown on SIGTERM + iniset "$file" uwsgi hook-master-start "unix_signal:15 gracefully_kill_them_all" # Override the default size for headers from the 4k default. iniset "$file" uwsgi buffer-size 65535 # Make sure the client doesn't try to re-use the connection. @@ -316,6 +321,11 @@ function write_local_uwsgi_http_config { iniset "$file" uwsgi plugins python # uwsgi recommends this to prevent thundering herd on accept. iniset "$file" uwsgi thunder-lock true + # Set hook to trigger graceful shutdown on SIGTERM + iniset "$file" uwsgi hook-master-start "unix_signal:15 gracefully_kill_them_all" + # Set worker-reload-mercy so that worker will not exit till the time + # configured after graceful shutdown + iniset "$file" uwsgi worker-reload-mercy $WORKER_TIMEOUT # Override the default size for headers from the 4k default. iniset "$file" uwsgi buffer-size 65535 # Make sure the client doesn't try to re-use the connection. diff --git a/stackrc b/stackrc index d60e186448..0ffcb67219 100644 --- a/stackrc +++ b/stackrc @@ -793,6 +793,9 @@ SERVICE_TIMEOUT=${SERVICE_TIMEOUT:-60} # Service graceful shutdown timeout SERVICE_GRACEFUL_SHUTDOWN_TIMEOUT=${SERVICE_GRACEFUL_SHUTDOWN_TIMEOUT:-5} +# Service graceful shutdown timeout +WORKER_TIMEOUT=${WORKER_TIMEOUT:-90} + # Support alternative yum -- in future Fedora 'dnf' will become the # only supported installer, but for now 'yum' and 'dnf' are both # available in parallel with compatible CLIs. Allow manual switching