Ensure preloaded apps are properly loaded by setting their internal markedForDeletion to false, and run apps that have it set to null

Currently preloaded apps don't run because their markedForDeletion field in the database is null. In this commit we set it to false, and we
also change the startup check to also run any apps that have markedForDeletion as null (which should now never happen, but is still good as a backup
plan in case something else fails and to avoid regressions).

Change-Type: patch
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
This commit is contained in:
Pablo Carranza Velez 2017-10-23 09:44:59 -07:00
parent 3f198fc6aa
commit a87c6682a2
2 changed files with 2 additions and 1 deletions

View File

@ -882,7 +882,7 @@ application.initialize = ->
listenToEvents()
getAndApplyDeviceConfig()
.then ->
knex('app').whereNot(markedForDeletion: true).select()
knex('app').whereNot(markedForDeletion: true).orWhereNull('markedForDeletion').select()
.map (app) ->
unlockAndStart(app) if !application.localMode and !device.shuttingDown
.catch (error) ->

View File

@ -43,6 +43,7 @@ loadPreloadedApps = ->
utils.extendEnvVars(app.env, userConfig.uuid, userConfig.deviceApiKey, app.appId, app.name, app.commit)
.then (extendedEnv) ->
app.env = JSON.stringify(extendedEnv)
app.markedForDeletion = false
_.merge(devConfig, app.config)
app.config = JSON.stringify(app.config)
knex('app').insert(app)