This reverts commit 15b0a5f1eb849a30bcea9a1e437e9a88ae2c6f92.
The change had an assumption that a service
is properly configured even when it isn't enabled.
The assumption is not true.
Change-Id: Ib5a8ffe63eaec15bc29bfdd133db7169507bab82
Closes-Bug: #1698129
... | ... |
@@ -1508,13 +1508,8 @@ EOF |
1508 | 1508 |
|
1509 | 1509 |
} |
1510 | 1510 |
|
1511 |
-# Defines a systemd service which can be enabled and started later on. |
|
1512 |
-# arg1: The openstack service name ('n-cpu', 'c-sch', ...). |
|
1513 |
-# arg2: The command to start (e.g. path to service binary + config files). |
|
1514 |
-# arg3: The group which owns the process. |
|
1515 |
-# arg4: The user which owns the process. |
|
1516 |
-# Returns: The systemd service name which got defined. |
|
1517 |
-function _define_systemd_service { |
|
1511 |
+# Helper function to build a basic unit file and run it under systemd. |
|
1512 |
+function _run_under_systemd { |
|
1518 | 1513 |
local service=$1 |
1519 | 1514 |
local command="$2" |
1520 | 1515 |
local cmd=$command |
... | ... |
@@ -1529,7 +1524,9 @@ function _define_systemd_service { |
1529 | 1529 |
else |
1530 | 1530 |
write_user_unit_file $systemd_service "$cmd" "$group" "$user" |
1531 | 1531 |
fi |
1532 |
- echo $systemd_service |
|
1532 |
+ |
|
1533 |
+ $SYSTEMCTL enable $systemd_service |
|
1534 |
+ $SYSTEMCTL start $systemd_service |
|
1533 | 1535 |
} |
1534 | 1536 |
|
1535 | 1537 |
# Helper to remove the ``*.failure`` files under ``$SERVICE_DIR/$SCREEN_NAME``. |
... | ... |
@@ -1570,19 +1567,11 @@ function run_process { |
1570 | 1570 |
local user=$4 |
1571 | 1571 |
|
1572 | 1572 |
local name=$service |
1573 |
- local systemd_service |
|
1574 | 1573 |
|
1575 | 1574 |
time_start "run_process" |
1576 |
- # Note we deliberately make all service files, even if the service |
|
1577 |
- # isn't enabled, so it can be enabled by a dev manually on command |
|
1578 |
- # line. |
|
1579 |
- if [[ "$USE_SYSTEMD" = "True" ]]; then |
|
1580 |
- systemd_service=$(_define_systemd_service "$name" "$command" "$group" "$user") |
|
1581 |
- fi |
|
1582 | 1575 |
if is_service_enabled $service; then |
1583 | 1576 |
if [[ "$USE_SYSTEMD" = "True" ]]; then |
1584 |
- $SYSTEMCTL enable $systemd_service |
|
1585 |
- $SYSTEMCTL start $systemd_service |
|
1577 |
+ _run_under_systemd "$name" "$command" "$group" "$user" |
|
1586 | 1578 |
elif [[ "$USE_SCREEN" = "True" ]]; then |
1587 | 1579 |
if [[ "$user" == "root" ]]; then |
1588 | 1580 |
command="sudo $command" |