mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-05-05 10:32:56 +00:00
Enable control of API poll interval through Device Variables
This commit is contained in:
parent
f7c81f987f
commit
e43e11b3c1
@ -289,6 +289,10 @@ joinErrorMessages = (failures) ->
|
|||||||
connectivityCheck = (val) ->
|
connectivityCheck = (val) ->
|
||||||
if val == 'false' then utils.disableCheck(true) else utils.disableCheck(false)
|
if val == 'false' then utils.disableCheck(true) else utils.disableCheck(false)
|
||||||
|
|
||||||
|
# Callback function to set the API poll interval dynamically.
|
||||||
|
apiPollInterval = (val) ->
|
||||||
|
config.appUpdatePollInterval = config.checkInt(val) ? 60000
|
||||||
|
|
||||||
# Callback function to enable/disable logs
|
# Callback function to enable/disable logs
|
||||||
resinLogControl = (val) ->
|
resinLogControl = (val) ->
|
||||||
if val == 'false' then logger.disableLogPublishing(true) else logger.disableLogPublishing(false)
|
if val == 'false' then logger.disableLogPublishing(true) else logger.disableLogPublishing(false)
|
||||||
@ -301,6 +305,7 @@ specialActionEnvVars =
|
|||||||
'RESIN_OVERRIDE_LOCK': null
|
'RESIN_OVERRIDE_LOCK': null
|
||||||
'_RESIN_VPN_CONTROL': vpnControl
|
'_RESIN_VPN_CONTROL': vpnControl
|
||||||
'_RESIN_CONNECTIVTY_CHECK': connectivityCheck
|
'_RESIN_CONNECTIVTY_CHECK': connectivityCheck
|
||||||
|
'_RESIN_POLL_INTERVAL': apiPollInterval
|
||||||
'_RESIN_LOG_CONTROL': resinLogControl
|
'_RESIN_LOG_CONTROL': resinLogControl
|
||||||
|
|
||||||
executedSpecialActionEnvVars = {}
|
executedSpecialActionEnvVars = {}
|
||||||
@ -491,6 +496,7 @@ application.update = update = (force) ->
|
|||||||
.finally ->
|
.finally ->
|
||||||
# Set the updating as finished in its own block, so it never has to worry about other code stopping this.
|
# Set the updating as finished in its own block, so it never has to worry about other code stopping this.
|
||||||
updateStatus.state = UPDATE_IDLE
|
updateStatus.state = UPDATE_IDLE
|
||||||
|
setTimeout(update, config.appUpdatePollInterval)
|
||||||
|
|
||||||
application.initialize = ->
|
application.initialize = ->
|
||||||
knex('app').select()
|
knex('app').select()
|
||||||
@ -503,9 +509,6 @@ application.initialize = ->
|
|||||||
console.error('Error starting apps:', error)
|
console.error('Error starting apps:', error)
|
||||||
.then ->
|
.then ->
|
||||||
utils.mixpanelTrack('Start application update poll', {interval: config.appUpdatePollInterval})
|
utils.mixpanelTrack('Start application update poll', {interval: config.appUpdatePollInterval})
|
||||||
setInterval(->
|
|
||||||
application.update()
|
|
||||||
, config.appUpdatePollInterval)
|
|
||||||
application.update()
|
application.update()
|
||||||
|
|
||||||
module.exports = (uuid) ->
|
module.exports = (uuid) ->
|
||||||
|
@ -26,3 +26,4 @@ module.exports = config =
|
|||||||
successMessage: 'SUPERVISOR OK'
|
successMessage: 'SUPERVISOR OK'
|
||||||
forceApiSecret: process.env.RESIN_SUPERVISOR_SECRET ? null
|
forceApiSecret: process.env.RESIN_SUPERVISOR_SECRET ? null
|
||||||
vpnStatusPath: process.env.VPN_STATUS_PATH ? '/mnt/root/run/openvpn/vpn_status'
|
vpnStatusPath: process.env.VPN_STATUS_PATH ? '/mnt/root/run/openvpn/vpn_status'
|
||||||
|
checkInt: checkInt
|
||||||
|
@ -131,7 +131,7 @@ exports.extendEnvVars = (env, uuid) ->
|
|||||||
_.extend(newEnv, env)
|
_.extend(newEnv, env)
|
||||||
return Promise.props(newEnv)
|
return Promise.props(newEnv)
|
||||||
|
|
||||||
# Disable VPN - Uses am enable String
|
# VPN Control - Uses an enable Boolean
|
||||||
exports.VPNControl = (enable) ->
|
exports.VPNControl = (enable) ->
|
||||||
callback = (error, response, body ) ->
|
callback = (error, response, body ) ->
|
||||||
if !error && response.statusCode == 200
|
if !error && response.statusCode == 200
|
||||||
|
Loading…
x
Reference in New Issue
Block a user