mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-19 13:47:54 +00:00
Turn the connectivity check into a singleton, so we only have one running.
This commit is contained in:
parent
2557ebcfc2
commit
5e380fb66a
@ -11,7 +11,7 @@ utils.mixpanelTrack('Supervisor start')
|
||||
|
||||
|
||||
console.log('Starting connectivity check..')
|
||||
utils.connectivityCheck(true)
|
||||
utils.connectivityCheck()
|
||||
|
||||
knex('config').select('value').where(key: 'uuid').then ([ uuid ]) ->
|
||||
if not uuid?.value
|
||||
|
@ -77,7 +77,7 @@ exports.checkConnectivity = ->
|
||||
|
||||
exports.connectivityCheck = do ->
|
||||
connectivityState = true # Used to prevent multiple messages when disconnected
|
||||
(continuous = false) ->
|
||||
_check = ->
|
||||
utils.checkConnectivity()
|
||||
.then (connected) ->
|
||||
if not connected
|
||||
@ -89,12 +89,10 @@ exports.connectivityCheck = do ->
|
||||
.then ->
|
||||
# Clear the blinks after 2 second
|
||||
clearInterval(interval)
|
||||
utils.connectivityCheck(continuous)
|
||||
_check()
|
||||
else
|
||||
if not connectivityState
|
||||
console.log('Internet Connectivity: OK')
|
||||
connectivityState = true
|
||||
if continuous
|
||||
setTimeout(->
|
||||
utils.connectivityCheck(continuous)
|
||||
, 10 * 1000) # Every 10 seconds perform this check.
|
||||
setTimeout(_check, 10 * 1000) # Every 10 seconds perform this check.
|
||||
return _.once(_check)
|
||||
|
Loading…
Reference in New Issue
Block a user