mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-06-01 15:20:51 +00:00
Deal with int env vars more nicely (actually parse them and check they're valid ints)
This commit is contained in:
parent
10012a48cf
commit
c7c1c45f38
@ -1,3 +1,12 @@
|
|||||||
|
checkInt = (s) ->
|
||||||
|
# Make sure `s` exists and is not an empty string.
|
||||||
|
if !s
|
||||||
|
return
|
||||||
|
i = parseInt(s, 10)
|
||||||
|
if isNaN(i)
|
||||||
|
return
|
||||||
|
return i
|
||||||
|
|
||||||
module.exports = config =
|
module.exports = config =
|
||||||
apiEndpoint: process.env.API_ENDPOINT ? 'https://api.resin.io'
|
apiEndpoint: process.env.API_ENDPOINT ? 'https://api.resin.io'
|
||||||
registryEndpoint: process.env.REGISTRY_ENDPOINT ? 'registry.resin.io'
|
registryEndpoint: process.env.REGISTRY_ENDPOINT ? 'registry.resin.io'
|
||||||
@ -9,8 +18,8 @@ module.exports = config =
|
|||||||
localImage: process.env.SUPERVISOR_IMAGE ? 'resin/rpi-supervisor'
|
localImage: process.env.SUPERVISOR_IMAGE ? 'resin/rpi-supervisor'
|
||||||
configMountPoint: process.env.CONFIG_MOUNT_POINT ? '/mnt/mmcblk0p1/config.json'
|
configMountPoint: process.env.CONFIG_MOUNT_POINT ? '/mnt/mmcblk0p1/config.json'
|
||||||
ledFile: process.env.LED_FILE ? '/sys/class/leds/led0/brightness'
|
ledFile: process.env.LED_FILE ? '/sys/class/leds/led0/brightness'
|
||||||
bootstrapRetryDelay: process.env.BOOTSTRAP_RETRY_DELAY_MS ? 30000
|
bootstrapRetryDelay: checkInt(process.env.BOOTSTRAP_RETRY_DELAY_MS) ? 30000
|
||||||
restartSuccessTimeout: process.env.RESTART_SUCCESS_TIMEOUT ? 60000
|
restartSuccessTimeout: checkInt(process.env.RESTART_SUCCESS_TIMEOUT) ? 60000
|
||||||
successMessage: 'SUPERVISOR OK'
|
successMessage: 'SUPERVISOR OK'
|
||||||
|
|
||||||
config.heartbeatEndpoint = config.apiEndpoint + '/ping'
|
config.heartbeatEndpoint = config.apiEndpoint + '/ping'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user