Skip to content

Commit ce1579a

Browse files
committed
[fix] delay stop until configuration is applied
fixes #172
1 parent 4549659 commit ce1579a

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

openwisp-config/files/openwisp.init

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,8 @@ service_triggers() {
8282
procd_add_reload_trigger openwisp
8383
}
8484

85-
stop_service() {
86-
logger -s "$PROG_NAME stopping" -t openwisp -p daemon.info
87-
}
88-
89-
reload_service() {
90-
logger -s "$PROG_NAME received reload trigger" -t openwisp -p daemon.info
91-
# avoid reloading while configuration is being applied
85+
wait_applying_config() {
86+
# avoid stopping/reloading while configuration is being applied
9287
# will wait for a maximum of 30 seconds
9388
for _ in $(seq 1 30); do
9489
if [ -f "$CONTROL_FILE" ]; then
@@ -98,5 +93,15 @@ reload_service() {
9893
fi
9994
done
10095
rm -f "$CONTROL_FILE"
96+
}
97+
98+
stop_service() {
99+
logger -s "$PROG_NAME stopping" -t openwisp -p daemon.info
100+
wait_applying_config
101+
}
102+
103+
reload_service() {
104+
logger -s "$PROG_NAME received reload trigger" -t openwisp -p daemon.info
105+
wait_applying_config
101106
start
102107
}

0 commit comments

Comments
 (0)