mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-05-04 18:12:56 +00:00
When apiEndpoint is not defined, work in offline mode
The supervisor uses an `API_ENDPOINT` environment variable to define what API to register to. Up to now this has been defaulted to `https://api.resin.io`. (In Resin OS devices this environment variable ultimately comes from config.json). This commit changes the behavior so that an empty value of that environment variable causes the supervisor to work in "offline mode", i.e. not connected to a remote server. Basically only preloaded apps and the supervisor API work in this mode. The config.json `supervisorOfflineMode` field still works for backwards compatibility, but we'll treat it as deprecated and it should be removed eventually. Change-Type: minor Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
This commit is contained in:
parent
1e7bdad7a9
commit
00b53bd03e
@ -175,7 +175,7 @@ bootstrapper.startBootstrapping = ->
|
|||||||
readConfig()
|
readConfig()
|
||||||
.then (configFromFile) ->
|
.then (configFromFile) ->
|
||||||
userConfig = configFromFile
|
userConfig = configFromFile
|
||||||
bootstrapper.offlineMode = Boolean(userConfig.supervisorOfflineMode)
|
bootstrapper.offlineMode = !Boolean(config.apiEndpoint) or Boolean(userConfig.supervisorOfflineMode)
|
||||||
knex('config').select('value').where(key: 'uuid')
|
knex('config').select('value').where(key: 'uuid')
|
||||||
.then ([ uuid ]) ->
|
.then ([ uuid ]) ->
|
||||||
if uuid?.value
|
if uuid?.value
|
||||||
|
@ -4,7 +4,7 @@ dockerRoot = checkString(process.env.DOCKER_ROOT) ? '/mnt/root/var/lib/rce'
|
|||||||
|
|
||||||
# Defaults needed for both gosuper and node supervisor are declared in entry.sh
|
# Defaults needed for both gosuper and node supervisor are declared in entry.sh
|
||||||
module.exports =
|
module.exports =
|
||||||
apiEndpoint: checkString(process.env.API_ENDPOINT) ? 'https://api.resin.io'
|
apiEndpoint: checkString(process.env.API_ENDPOINT)
|
||||||
apiTimeout: checkInt(process.env.API_TIMEOUT, positive: true) ? 15 * 60 * 1000
|
apiTimeout: checkInt(process.env.API_TIMEOUT, positive: true) ? 15 * 60 * 1000
|
||||||
listenPort: checkInt(process.env.LISTEN_PORT, positive: true) ? 80
|
listenPort: checkInt(process.env.LISTEN_PORT, positive: true) ? 80
|
||||||
gosuperAddress: "http://unix:#{process.env.GOSUPER_SOCKET}:"
|
gosuperAddress: "http://unix:#{process.env.GOSUPER_SOCKET}:"
|
||||||
|
@ -18,7 +18,7 @@ device = require './device'
|
|||||||
exports.supervisorVersion = require('./lib/supervisor-version')
|
exports.supervisorVersion = require('./lib/supervisor-version')
|
||||||
|
|
||||||
configJson = require('/boot/config.json')
|
configJson = require('/boot/config.json')
|
||||||
if !Boolean(configJson.supervisorOfflineMode)
|
if Boolean(config.apiEndpoint) and !Boolean(configJson.supervisorOfflineMode)
|
||||||
mixpanelClient = mixpanel.init(config.mixpanelToken)
|
mixpanelClient = mixpanel.init(config.mixpanelToken)
|
||||||
else
|
else
|
||||||
mixpanelClient = { track: _.noop }
|
mixpanelClient = { track: _.noop }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user