Don't cache config.json

This commit is contained in:
Pagan Gazzard 2015-05-04 12:45:50 +01:00 committed by Pablo Carranza Vélez
parent 7bc0a7d869
commit ab26c6a401
2 changed files with 7 additions and 5 deletions

View File

@ -1,3 +1,5 @@
* Stop caching config.json, avoids a race that could cause getting stuck repeatedly trying to register [Page]
# v0.0.13
* Bind mount /etc/resolv.conf as ro for application containers and supervisor [Praneeth]

View File

@ -28,10 +28,10 @@ registerDevice = (apiKey, userId, applicationId, deviceType, uuid) ->
module.exports = ->
# Load config file
userConfig = require('/boot/config.json')
fs.readFileAsync('/boot/config.json', 'utf8')
.then(JSON.parse)
.then (userConfig) ->
userConfig.deviceType ?= 'raspberry-pi'
Promise.try ->
if userConfig.uuid? and userConfig.registered_at?
return userConfig
registerDevice(userConfig.apiKey, userConfig.userId, userConfig.applicationId, userConfig.deviceType, userConfig.uuid)
@ -40,7 +40,7 @@ module.exports = ->
userConfig.deviceId = device.id
fs.writeFileAsync('/boot/config.json', JSON.stringify(userConfig))
.return(userConfig)
.then ->
.then (userConfig) ->
console.log('Finishing bootstrapping')
Promise.all([
knex('config').truncate()