uwsgi is a different service type under systemd and shouldn't be run as
a standard oneshot type. The uwsgi docs outline a good pattern for
writing systemd unit files:
http://uwsgi-docs.readthedocs.io/en/latest/Systemd.html
This commit takes those suggestions and creates a separate path for
writing uwsgi unit files.
Change-Id: I9b541b86781afdded311dba058cedd783e1a0dfa
| ... | ... |
@@ -1467,6 +1467,32 @@ function write_user_unit_file {
|
| 1467 | 1467 |
$SYSTEMCTL daemon-reload |
| 1468 | 1468 |
} |
| 1469 | 1469 |
|
| 1470 |
+function write_uwsgi_user_unit_file {
|
|
| 1471 |
+ local service=$1 |
|
| 1472 |
+ local command="$2" |
|
| 1473 |
+ local group=$3 |
|
| 1474 |
+ local user=$4 |
|
| 1475 |
+ local unitfile="$SYSTEMD_DIR/$service" |
|
| 1476 |
+ mkdir -p $SYSTEMD_DIR |
|
| 1477 |
+ |
|
| 1478 |
+ iniset -sudo $unitfile "Unit" "Description" "Devstack $service" |
|
| 1479 |
+ iniset -sudo $unitfile "Service" "User" "$user" |
|
| 1480 |
+ iniset -sudo $unitfile "Service" "ExecStart" "$command" |
|
| 1481 |
+ iniset -sudo $unitfile "Service" "Type" "notify" |
|
| 1482 |
+ iniset -sudo $unitfile "Service" "KillSignal" "SIGQUIT" |
|
| 1483 |
+ iniset -sudo $unitfile "Service" "Restart" "Always" |
|
| 1484 |
+ iniset -sudo $unitfile "Service" "NotifyAccess" "all" |
|
| 1485 |
+ iniset -sudo $unitfile "Service" "RestartForceExitStatus" "100" |
|
| 1486 |
+ |
|
| 1487 |
+ if [[ -n "$group" ]]; then |
|
| 1488 |
+ iniset -sudo $unitfile "Service" "Group" "$group" |
|
| 1489 |
+ fi |
|
| 1490 |
+ iniset -sudo $unitfile "Install" "WantedBy" "multi-user.target" |
|
| 1491 |
+ |
|
| 1492 |
+ # changes to existing units sometimes need a refresh |
|
| 1493 |
+ $SYSTEMCTL daemon-reload |
|
| 1494 |
+} |
|
| 1495 |
+ |
|
| 1470 | 1496 |
function _run_under_systemd {
|
| 1471 | 1497 |
local service=$1 |
| 1472 | 1498 |
local command="$2" |
| ... | ... |
@@ -1474,7 +1500,11 @@ function _run_under_systemd {
|
| 1474 | 1474 |
local systemd_service="devstack@$service.service" |
| 1475 | 1475 |
local group=$3 |
| 1476 | 1476 |
local user=${4:-$STACK_USER}
|
| 1477 |
- write_user_unit_file $systemd_service "$cmd" "$group" "$user" |
|
| 1477 |
+ if [[ "$command" =~ "uwsgi" ]] ; then |
|
| 1478 |
+ write_uwsgi_user_unit_file $systemd_service "$cmd" "$group" "$user" |
|
| 1479 |
+ else |
|
| 1480 |
+ write_user_unit_file $systemd_service "$cmd" "$group" "$user" |
|
| 1481 |
+ fi |
|
| 1478 | 1482 |
|
| 1479 | 1483 |
$SYSTEMCTL enable $systemd_service |
| 1480 | 1484 |
$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 |