Skip to content

Commit c087c71

Browse files
yamtsdague
authored andcommitted
Revert "systemd: Always create the systemd unit files"
This reverts commit 15b0a5f. 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
1 parent 15b0a5f commit c087c71

1 file changed

Lines changed: 6 additions & 17 deletions

File tree

functions-common

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,13 +1508,8 @@ EOF
15081508

15091509
}
15101510

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 {
15181513
local service=$1
15191514
local command="$2"
15201515
local cmd=$command
@@ -1529,7 +1524,9 @@ function _define_systemd_service {
15291524
else
15301525
write_user_unit_file $systemd_service "$cmd" "$group" "$user"
15311526
fi
1532-
echo $systemd_service
1527+
1528+
$SYSTEMCTL enable $systemd_service
1529+
$SYSTEMCTL start $systemd_service
15331530
}
15341531

15351532
# Helper to remove the ``*.failure`` files under ``$SERVICE_DIR/$SCREEN_NAME``.
@@ -1570,19 +1567,11 @@ function run_process {
15701567
local user=$4
15711568

15721569
local name=$service
1573-
local systemd_service
15741570

15751571
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
15821572
if is_service_enabled $service; then
15831573
if [[ "$USE_SYSTEMD" = "True" ]]; then
1584-
$SYSTEMCTL enable $systemd_service
1585-
$SYSTEMCTL start $systemd_service
1574+
_run_under_systemd "$name" "$command" "$group" "$user"
15861575
elif [[ "$USE_SCREEN" = "True" ]]; then
15871576
if [[ "$user" == "root" ]]; then
15881577
command="sudo $command"

0 commit comments

Comments
 (0)