Skip to content

Commit

Permalink
Smarter reload #13
Browse files Browse the repository at this point in the history
Fixes #13
  • Loading branch information
nemesifier committed Feb 25, 2016
1 parent 79fda64 commit 99e863b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
7 changes: 7 additions & 0 deletions openwisp-config/files/openwisp.agent
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ CONFIGURATION_BACKUP="$WORKING_DIR/backup.tar.gz"
REGISTRATION_PARAMETERS="$WORKING_DIR/registration_parameters"
TEST_CHECKSUM="$WORKING_DIR/test_checksum"
STATUS_REPORT="$WORKING_DIR/status_report"
APPLYING_CONF="$WORKING_DIR/applying_conf"
REGISTRATION_URL="$URL/controller/register/"
DEFAULT_DIR="/etc/openwisp-config-defaults"
FETCH_COMMAND="curl -s"
Expand Down Expand Up @@ -292,12 +293,18 @@ update_configuration() {
return 3
fi

# control file to avoid reloading the agent while
# configuration is still being applied
touch $APPLYING_CONF

if [ "$TEST_CONFIG" == "1" ]; then
test_configuration $CONFIGURATION_ARCHIVE
else
apply_configuration $CONFIGURATION_ARCHIVE
fi

rm $APPLYING_CONF

if [ "$?" == "0" ]; then
logger -s "Configuration applied" \
-t openwisp \
Expand Down
17 changes: 17 additions & 0 deletions openwisp-config/files/openwisp.init
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,20 @@ stop_service() {
-t openwisp \
-p daemon.info
}

reload_service() {
logger -s "$PROG_NAME received reload trigger" \
-t openwisp \
-p daemon.info
# avoid reloading while configuration is being applied
# will wait for a maximum of 30 seconds
for i in $(seq 1 30); do
if [ -f "/tmp/openwisp/applying_conf" ]; then
sleep 1
else
break
fi
done
# reload
start
}

0 comments on commit 99e863b

Please sign in to comment.