Skip to content

Commit f08c7df

Browse files
authored
[feature] Add extra interval parameters for retries
1 parent 30ee01d commit f08c7df

5 files changed

Lines changed: 15 additions & 4 deletions

File tree

README.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ UCI configuration options must go in ``/etc/config/openwisp``.
6969

7070
- ``url``: url of controller, eg: ``https://controller.openwisp.org``
7171
- ``interval``: time in seconds between checks for changes to the configuration, defaults to ``120``
72+
- ``management_interval``: time in seconds between the management ip discovery attempts, defaults to ``$interval/12``
73+
- ``registration_interval``: time in seconds between the registration attempts, defaults to ``$interval/4``
7274
- ``verify_ssl``: whether SSL verification must be performed or not, defaults to ``1``
7375
- ``shared_secret``: shared secret, needed for `Automatic registration`_
7476
- ``consistent_key``: whether `Consistent key generation`_ is enabled or not, defaults to ``1``

openwisp-config/files/openwisp-nossl.config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
config controller 'http'
55
#option url 'http://openwisp2.mynetwork.com'
66
#option interval '120'
7+
#option management_interval '10'
8+
#option registration_interval '30'
79
option verify_ssl '0'
810
#option shared_secret ''
911
#option consistent_key '1'

openwisp-config/files/openwisp-ssl.config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
config controller 'http'
55
#option url 'https://openwisp2.mynetwork.com'
66
#option interval '120'
7+
#option management_interval '10'
8+
#option registration_interval '30'
79
#option verify_ssl '1'
810
#option shared_secret ''
911
#option consistent_key '1'

openwisp-config/files/openwisp.agent

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ while [ -n "$1" ]; do
66
--version|-v) export VERSION=1; break;;
77
--url) export URL=${2%/}; shift;; # strip trailing slash
88
--interval) export INTERVAL=$2; shift;;
9+
--management_interval) export MANAGEMENT_INTERVAL="$2"; shift;;
10+
--registration_interval) export REGISTRATION_INTERVAL="$2"; shift;;
911
--verify-ssl) export VERIFY_SSL=$2; shift;;
1012
--uuid) export UUID="$2"; shift;;
1113
--key) export KEY="$2"; shift;;
@@ -60,6 +62,8 @@ if ([ -z "$UUID" ] || [ -z "$KEY" ]) && [ -z "$SHARED_SECRET" ]; then
6062
fi
6163

6264
INTERVAL=${INTERVAL:-120}
65+
MANAGEMENT_INTERVAL=${MANAGEMENT_INTERVAL:-$(expr $INTERVAL / 12)}
66+
REGISTRATION_INTERVAL=${REGISTRATION_INTERVAL:-$(expr $INTERVAL / 4)}
6367
VERIFY_SSL=${VERIFY_SSL:-1}
6468
MERGE_CONFIG=${MERGE_CONFIG:-1}
6569
TEST_CONFIG=${TEST_CONFIG:-1}
@@ -641,12 +645,11 @@ discover_management_ip(){
641645
MANAGEMENT_IP=$(/usr/sbin/openwisp-get-address $MANAGEMENT_INTERFACE)
642646

643647
if [ -z "$MANAGEMENT_IP" ]; then
644-
retry_after=$(expr $INTERVAL / 12)
645648
logger -s "management interface not ready (attempt $attempt of $MAX_ATTEMPTS)" \
646649
-t openwisp \
647650
-p daemon.notice
648651
if [ $attempt -lt $MAX_ATTEMPTS ]; then
649-
sleep $retry_after
652+
sleep $MANAGEMENT_INTERVAL
650653
else
651654
logger -s "could not determine ip address of management interface, giving up..." \
652655
-t openwisp \
@@ -674,11 +677,11 @@ handle_sigusr1() {
674677
# otherwise perform registration
675678
if [ -z "$UUID" ] || [ -z "$KEY" ]; then
676679
# do not crash if controller can't be reached
677-
# but retry every ($INTERVAL / 4) seconds
680+
# but retry every $REGISTRATION_INTERVAL seconds
678681
# (device might be unplugged, unconfigured or connecting)
679682
until register
680683
do
681-
sleep $(expr $INTERVAL / 4)
684+
sleep $REGISTRATION_INTERVAL
682685
done
683686
touch "$BOOTUP"
684687
fi

openwisp-config/files/openwisp.init

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ parse_config() {
2020
local cfg="$1"
2121
add_option "$cfg" "--url" url
2222
add_option "$cfg" "--interval" interval
23+
add_option "$cfg" "--management_interval" management_interval
24+
add_option "$cfg" "--registration_interval" registration_interval
2325
add_option "$cfg" "--verify-ssl" verify_ssl
2426
add_option "$cfg" "--uuid" uuid
2527
add_option "$cfg" "--key" key

0 commit comments

Comments
 (0)