Browse code

Enable reloadable config in services

uwsgi services:
[1] By default uwsgi is set to exit on reload this breaks config reloading
of the service [1][2]. It needs to be set to 'false'.
[2] Requires to add 'systemctl reload' command support by adding ExecReload
in unit file.

Non uwsgi services:
[1] Non uwsgi services only requires to add ExecReload in unit file.

There was a similar patch submitted by Matthew Treinish [3] but it was
already set to workflow +1(not merged as having dependency on other patch)
and it was having some issues as specified in comment and missing reload
functionality for other services.

[1] https://etherpad.openstack.org/p/uwsgi-issues
[2] http://uwsgi-docs.readthedocs.io/en/latest/Options.html#exit-on-reload
[3] https://review.openstack.org/#/c/490904/2

Change-Id: I78f5e9d4574671c74a52af64724946feb41c2d7a

Dinesh Bhor authored on 2017/09/05 18:10:32
Showing 2 changed files
... ...
@@ -45,6 +45,7 @@ declare -A -g GITBRANCH
45 45
 declare -A -g GITDIR
46 46
 
47 47
 TRACK_DEPENDS=${TRACK_DEPENDS:-False}
48
+KILL_PATH="$(which kill)"
48 49
 
49 50
 # Save these variables to .stackenv
50 51
 STACK_ENV_VARS="BASE_SQL_CONN DATA_DIR DEST ENABLED_SERVICES HOST_IP \
... ...
@@ -1453,6 +1454,7 @@ function write_user_unit_file {
1453 1453
     iniset -sudo $unitfile "Service" "ExecStart" "$command"
1454 1454
     iniset -sudo $unitfile "Service" "KillMode" "process"
1455 1455
     iniset -sudo $unitfile "Service" "TimeoutStopSec" "infinity"
1456
+    iniset -sudo $unitfile "Service" "ExecReload" "$KILL_PATH -HUP \$MAINPID"
1456 1457
     if [[ -n "$group" ]]; then
1457 1458
         iniset -sudo $unitfile "Service" "Group" "$group"
1458 1459
     fi
... ...
@@ -1474,6 +1476,7 @@ function write_uwsgi_user_unit_file {
1474 1474
     iniset -sudo $unitfile "Service" "SyslogIdentifier" "$service"
1475 1475
     iniset -sudo $unitfile "Service" "User" "$user"
1476 1476
     iniset -sudo $unitfile "Service" "ExecStart" "$command"
1477
+    iniset -sudo $unitfile "Service" "ExecReload" "$KILL_PATH -HUP \$MAINPID"
1477 1478
     iniset -sudo $unitfile "Service" "Type" "notify"
1478 1479
     iniset -sudo $unitfile "Service" "KillMode" "process"
1479 1480
     iniset -sudo $unitfile "Service" "Restart" "always"
... ...
@@ -259,7 +259,7 @@ function write_uwsgi_config {
259 259
     iniset "$file" uwsgi master true
260 260
     # Set die-on-term & exit-on-reload so that uwsgi shuts down
261 261
     iniset "$file" uwsgi die-on-term true
262
-    iniset "$file" uwsgi exit-on-reload true
262
+    iniset "$file" uwsgi exit-on-reload false
263 263
     # Set worker-reload-mercy so that worker will not exit till the time
264 264
     # configured after graceful shutdown
265 265
     iniset "$file" uwsgi worker-reload-mercy $WORKER_TIMEOUT
... ...
@@ -316,7 +316,7 @@ function write_local_uwsgi_http_config {
316 316
     iniset "$file" uwsgi master true
317 317
     # Set die-on-term & exit-on-reload so that uwsgi shuts down
318 318
     iniset "$file" uwsgi die-on-term true
319
-    iniset "$file" uwsgi exit-on-reload true
319
+    iniset "$file" uwsgi exit-on-reload false
320 320
     iniset "$file" uwsgi enable-threads true
321 321
     iniset "$file" uwsgi plugins python
322 322
     # uwsgi recommends this to prevent thundering herd on accept.