Retry the bootstrap process if it fails - this means that we remove a point of failure (the previous connectivity check barrier merely reduced the chance of hitting that failure point)

This commit is contained in:
Pagan Gazzard 2014-10-01 17:00:21 +01:00 committed by Pablo Carranza Vélez
parent 7866d7a9f7
commit f43afd4a95
2 changed files with 7 additions and 2 deletions

View File

@ -37,9 +37,13 @@ ensureConnected = (continuous = false) ->
knex('config').select('value').where(key: 'uuid').then ([ uuid ]) ->
if not uuid?.value
console.log('New device detected. Bootstrapping..')
ensureConnected().then ->
retryingBootstrap = ->
utils.mixpanelTrack('Device bootstrap')
bootstrap()
bootstrap().catch (err) ->
utils.mixpanelTrack("Device bootstrap failed due to #{err?.message}, retrying in #{config.bootstrapRetryDelay}ms")
Promise.delay(config.bootstrapRetryDelay)
.then(retryingBootstrap)
retryingBootstrap()
else
uuid.value
.then (uuid) ->

View File

@ -9,6 +9,7 @@ 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
successMessage: 'SUPERVISOR OK'
config.heartbeatEndpoint = config.apiEndpoint + '/ping'