Browse code

Merge "Handle uwsgi on systemd properly"

Jenkins authored on 2017/04/08 07:37:24
Showing 2 changed files
... ...
@@ -1482,6 +1482,32 @@ function write_user_unit_file {
1482 1482
     $SYSTEMCTL daemon-reload
1483 1483
 }
1484 1484
 
1485
+function write_uwsgi_user_unit_file {
1486
+    local service=$1
1487
+    local command="$2"
1488
+    local group=$3
1489
+    local user=$4
1490
+    local unitfile="$SYSTEMD_DIR/$service"
1491
+    mkdir -p $SYSTEMD_DIR
1492
+
1493
+    iniset -sudo $unitfile "Unit" "Description" "Devstack $service"
1494
+    iniset -sudo $unitfile "Service" "User" "$user"
1495
+    iniset -sudo $unitfile "Service" "ExecStart" "$command"
1496
+    iniset -sudo $unitfile "Service" "Type" "notify"
1497
+    iniset -sudo $unitfile "Service" "KillSignal" "SIGQUIT"
1498
+    iniset -sudo $unitfile "Service" "Restart" "Always"
1499
+    iniset -sudo $unitfile "Service" "NotifyAccess" "all"
1500
+    iniset -sudo $unitfile "Service" "RestartForceExitStatus" "100"
1501
+
1502
+    if [[ -n "$group" ]]; then
1503
+        iniset -sudo $unitfile "Service" "Group" "$group"
1504
+    fi
1505
+    iniset -sudo $unitfile "Install" "WantedBy" "multi-user.target"
1506
+
1507
+    # changes to existing units sometimes need a refresh
1508
+    $SYSTEMCTL daemon-reload
1509
+}
1510
+
1485 1511
 function _run_under_systemd {
1486 1512
     local service=$1
1487 1513
     local command="$2"
... ...
@@ -1489,7 +1515,11 @@ function _run_under_systemd {
1489 1489
     local systemd_service="devstack@$service.service"
1490 1490
     local group=$3
1491 1491
     local user=${4:-$STACK_USER}
1492
-    write_user_unit_file $systemd_service "$cmd" "$group" "$user"
1492
+    if [[ "$command" =~ "uwsgi" ]] ; then
1493
+        write_uwsgi_user_unit_file $systemd_service "$cmd" "$group" "$user"
1494
+    else
1495
+        write_user_unit_file $systemd_service "$cmd" "$group" "$user"
1496
+    fi
1493 1497
 
1494 1498
     $SYSTEMCTL enable $systemd_service
1495 1499
     $SYSTEMCTL start $systemd_service
... ...
@@ -604,8 +604,8 @@ function start_keystone {
604 604
         # TODO(sdague): we should really get down to a single keystone here
605 605
         enable_service key-p
606 606
         enable_service key-a
607
-        run_process key-p "$KEYSTONE_BIN_DIR/uwsgi $KEYSTONE_PUBLIC_UWSGI_FILE" ""
608
-        run_process key-a "$KEYSTONE_BIN_DIR/uwsgi $KEYSTONE_ADMIN_UWSGI_FILE" ""
607
+        run_process key-p "$KEYSTONE_BIN_DIR/uwsgi --ini $KEYSTONE_PUBLIC_UWSGI_FILE" ""
608
+        run_process key-a "$KEYSTONE_BIN_DIR/uwsgi --ini $KEYSTONE_ADMIN_UWSGI_FILE" ""
609 609
     fi
610 610
 
611 611
     echo "Waiting for keystone to start..."
... ...
@@ -638,6 +638,9 @@ function stop_keystone {
638 638
     if [ "$KEYSTONE_DEPLOY" == "mod_wsgi" ]; then
639 639
         disable_apache_site keystone
640 640
         restart_apache_server
641
+    else
642
+        stop_process key-p
643
+        stop_process key-a
641 644
     fi
642 645
     # Kill the Keystone screen window
643 646
     stop_process key