Skip to content

Commit 29215d9

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "systemd: Always create the systemd unit files"
2 parents 660f4ae + 15b0a5f commit 29215d9

2 files changed

Lines changed: 24 additions & 6 deletions

File tree

clean.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,13 @@ if [[ -n "$SCREEN_LOGDIR" ]] && [[ -d "$SCREEN_LOGDIR" ]]; then
125125
sudo rm -rf $SCREEN_LOGDIR
126126
fi
127127

128+
# Clean out the sytemd user unit files if systemd was used.
129+
if [[ "$USE_SYSTEMD" = "True" ]]; then
130+
sudo find $SYSTEMD_DIR -type f -name '*devstack@*service' -delete
131+
# Make systemd aware of the deletion.
132+
$SYSTEMCTL daemon-reload
133+
fi
134+
128135
# Clean up venvs
129136
DIRS_TO_CLEAN="$WHEELHOUSE ${PROJECT_VENV[@]} .config/openstack"
130137
rm -rf $DIRS_TO_CLEAN

functions-common

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

15091509
}
15101510

1511-
# Helper function to build a basic unit file and run it under systemd.
1512-
function _run_under_systemd {
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 {
15131518
local service=$1
15141519
local command="$2"
15151520
local cmd=$command
@@ -1524,9 +1529,7 @@ function _run_under_systemd {
15241529
else
15251530
write_user_unit_file $systemd_service "$cmd" "$group" "$user"
15261531
fi
1527-
1528-
$SYSTEMCTL enable $systemd_service
1529-
$SYSTEMCTL start $systemd_service
1532+
echo $systemd_service
15301533
}
15311534

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

15691572
local name=$service
1573+
local systemd_service
15701574

15711575
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
15721582
if is_service_enabled $service; then
15731583
if [[ "$USE_SYSTEMD" = "True" ]]; then
1574-
_run_under_systemd "$name" "$command" "$group" "$user"
1584+
$SYSTEMCTL enable $systemd_service
1585+
$SYSTEMCTL start $systemd_service
15751586
elif [[ "$USE_SCREEN" = "True" ]]; then
15761587
if [[ "$user" == "root" ]]; then
15771588
command="sudo $command"

0 commit comments

Comments
 (0)