mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-01-31 00:23:57 +00:00
Install apps in parallel to deleting them - also fixes SQL errors when there are no apps to install.
This commit is contained in:
parent
aad38a487f
commit
3c3e81a892
@ -109,13 +109,16 @@ exports.update = ->
|
|||||||
toBeInstalled = _.difference(remoteApps, localApps)
|
toBeInstalled = _.difference(remoteApps, localApps)
|
||||||
console.log(toBeInstalled)
|
console.log(toBeInstalled)
|
||||||
|
|
||||||
Promise.all(toBeRemoved.map(kill)).then(->
|
# Install the apps and add each to the db as they succeed
|
||||||
Promise.all(toBeInstalled.map(start))
|
promises = toBeInstalled.map (app) ->
|
||||||
).then(->
|
start(app).then ->
|
||||||
knex('app').whereIn('imageId', toBeRemoved).delete().then(->
|
knex('app').insert({imageId: app})
|
||||||
knex('app').insert(({imageId: app} for app in toBeInstalled))
|
# And delete all the ones to remove in one go
|
||||||
)
|
promises.push(
|
||||||
|
Promise.all(toBeRemoved.map(kill)).then ->
|
||||||
|
knex('app').whereIn('imageId', toBeRemoved).delete()
|
||||||
)
|
)
|
||||||
|
Promise.all(promises)
|
||||||
)
|
)
|
||||||
|
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user