mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-03-10 22:44:29 +00:00
Reorganize callbacks to utils and check for status accepted from go supervisor
This commit is contained in:
parent
e43e11b3c1
commit
9efcc59252
@ -285,28 +285,12 @@ joinErrorMessages = (failures) ->
|
||||
err.message or err
|
||||
"#{failures.length} error#{s}: #{messages.join(' - ')}"
|
||||
|
||||
# Callback function to enable/disable tcp pings
|
||||
connectivityCheck = (val) ->
|
||||
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
|
||||
resinLogControl = (val) ->
|
||||
if val == 'false' then logger.disableLogPublishing(true) else logger.disableLogPublishing(false)
|
||||
|
||||
# Callback function to enable/disable VPN
|
||||
vpnControl = (val) ->
|
||||
if val == 'false' then utils.VPNControl(false) else utils.VPNControl(true)
|
||||
|
||||
specialActionEnvVars =
|
||||
'RESIN_OVERRIDE_LOCK': null
|
||||
'_RESIN_VPN_CONTROL': vpnControl
|
||||
'_RESIN_CONNECTIVTY_CHECK': connectivityCheck
|
||||
'_RESIN_POLL_INTERVAL': apiPollInterval
|
||||
'_RESIN_LOG_CONTROL': resinLogControl
|
||||
'_RESIN_VPN_CONTROL': utils.vpnControl
|
||||
'_RESIN_CONNECTIVTY_CHECK': utils.connectivityCheck
|
||||
'_RESIN_POLL_INTERVAL': utils.apiPollInterval
|
||||
'_RESIN_LOG_CONTROL': utils.resinLogControl
|
||||
|
||||
executedSpecialActionEnvVars = {}
|
||||
|
||||
|
@ -7,11 +7,9 @@ mixpanel = require 'mixpanel'
|
||||
networkCheck = require 'network-checker'
|
||||
blink = require('blinking')(config.ledFile)
|
||||
url = require 'url'
|
||||
<<<<<<< HEAD
|
||||
randomHexString = require './lib/random-hex-string'
|
||||
=======
|
||||
request = require 'request'
|
||||
>>>>>>> Allow control of VPN + TCP check + Pub nub logs with Device Environment variables
|
||||
logger = require './lib/logger'
|
||||
|
||||
utils = exports
|
||||
|
||||
@ -67,7 +65,7 @@ exports.pauseCheck = (pause) ->
|
||||
pauseConnectivityCheck = pause
|
||||
|
||||
# disable: A Boolean to disable the connectivity checks
|
||||
exports.disableCheck = (disable) ->
|
||||
exports.disableCheck = disableCheck = (disable) ->
|
||||
disableConnectivityCheck = disable
|
||||
|
||||
# Call back for inotify triggered when the VPN status is changed.
|
||||
@ -131,11 +129,24 @@ exports.extendEnvVars = (env, uuid) ->
|
||||
_.extend(newEnv, env)
|
||||
return Promise.props(newEnv)
|
||||
|
||||
# VPN Control - Uses an enable Boolean
|
||||
exports.VPNControl = (enable) ->
|
||||
# Callback function to enable/disable tcp pings
|
||||
exports.connectivityCheck = (val) ->
|
||||
if val == 'false' then disableCheck(true) else disableCheck(false)
|
||||
|
||||
# Callback function to set the API poll interval dynamically.
|
||||
exports.apiPollInterval = (val) ->
|
||||
config.appUpdatePollInterval = config.checkInt(val) ? 60000
|
||||
|
||||
# Callback function to enable/disable logs
|
||||
exports.resinLogControl = (val) ->
|
||||
if val == 'false' then logger.disableLogPublishing(true) else logger.disableLogPublishing(false)
|
||||
|
||||
# Callback function to enable/disable VPN
|
||||
exports.vpnControl = (val) ->
|
||||
if val == 'false' then enable = false else enable = true
|
||||
callback = (error, response, body ) ->
|
||||
if !error && response.statusCode == 200
|
||||
if response.statusCode == 202
|
||||
console.log('VPN Enabled: ' + enable)
|
||||
else
|
||||
console.log(error)
|
||||
console.log('Error: ' + error + ' response:' + response.statusCode + ' body: ' + body.Data )
|
||||
request.post(config.gosuperAddress + '/v1/vpncontrol', { json: true, body: Enable: enable }, callback)
|
||||
|
Loading…
x
Reference in New Issue
Block a user