diff --git a/src/config.coffee b/src/config.coffee index 722ad663..e7fdddf4 100644 --- a/src/config.coffee +++ b/src/config.coffee @@ -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 = apiEndpoint: process.env.API_ENDPOINT ? 'https://api.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' configMountPoint: process.env.CONFIG_MOUNT_POINT ? '/mnt/mmcblk0p1/config.json' ledFile: process.env.LED_FILE ? '/sys/class/leds/led0/brightness' - bootstrapRetryDelay: process.env.BOOTSTRAP_RETRY_DELAY_MS ? 30000 - restartSuccessTimeout: process.env.RESTART_SUCCESS_TIMEOUT ? 60000 + bootstrapRetryDelay: checkInt(process.env.BOOTSTRAP_RETRY_DELAY_MS) ? 30000 + restartSuccessTimeout: checkInt(process.env.RESTART_SUCCESS_TIMEOUT) ? 60000 successMessage: 'SUPERVISOR OK' config.heartbeatEndpoint = config.apiEndpoint + '/ping'