mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-02-21 10:01:55 +00:00
Tell startNewSupervisor which image to start, we need to start the working image on a restart, and the new (possibly broken) image on update.
This commit is contained in:
parent
271719708c
commit
3b2b75998e
@ -21,16 +21,16 @@ currentContainerPromise =
|
|||||||
containerIdPromise.then (containerId) ->
|
containerIdPromise.then (containerId) ->
|
||||||
docker.getContainer(containerId)
|
docker.getContainer(containerId)
|
||||||
|
|
||||||
startNewSupervisor = (currentSupervisor, waitForSuccess = true) ->
|
startNewSupervisor = (currentSupervisor, image, waitForSuccess = true) ->
|
||||||
console.log('Creating supervisor container:', localImage)
|
console.log('Creating supervisor container:', image)
|
||||||
docker.createContainerAsync(
|
docker.createContainerAsync(
|
||||||
Image: localImage
|
Image: image
|
||||||
Cmd: [ '/start' ]
|
Cmd: [ '/start' ]
|
||||||
Volumes: config.supervisorContainer.Volumes
|
Volumes: config.supervisorContainer.Volumes
|
||||||
Env: currentSupervisor.Config.Env
|
Env: currentSupervisor.Config.Env
|
||||||
)
|
)
|
||||||
.tap (container) ->
|
.tap (container) ->
|
||||||
console.log('Starting supervisor container:', localImage)
|
console.log('Starting supervisor container:', image)
|
||||||
container.startAsync(
|
container.startAsync(
|
||||||
Privileged: true
|
Privileged: true
|
||||||
Binds: config.supervisorContainer.Binds
|
Binds: config.supervisorContainer.Binds
|
||||||
@ -85,7 +85,7 @@ currentConfigPromise = currentContainerPromise.then (container) ->
|
|||||||
console.log('Supervisor restart (for binds/mounts)')
|
console.log('Supervisor restart (for binds/mounts)')
|
||||||
restart = ->
|
restart = ->
|
||||||
# When restarting for just binds/mounts we just wait for the supervisor updates to start.
|
# When restarting for just binds/mounts we just wait for the supervisor updates to start.
|
||||||
startNewSupervisor(currentSupervisor, false)
|
startNewSupervisor(currentSupervisor, localImage, false)
|
||||||
.catch (err) ->
|
.catch (err) ->
|
||||||
console.error('Error restarting', err)
|
console.error('Error restarting', err)
|
||||||
# If there's an error just keep attempting to restart to get to a useful state.
|
# If there's an error just keep attempting to restart to get to a useful state.
|
||||||
@ -113,7 +113,7 @@ exports.initialised = currentConfigPromise.then (currentSupervisor) ->
|
|||||||
utils.mixpanelTrack('Supervisor up to date')
|
utils.mixpanelTrack('Supervisor up to date')
|
||||||
return
|
return
|
||||||
utils.mixpanelTrack('Supervisor update start', image: localImageId)
|
utils.mixpanelTrack('Supervisor update start', image: localImageId)
|
||||||
startNewSupervisor(currentSupervisor)
|
startNewSupervisor(currentSupervisor, remoteImage)
|
||||||
.catch (err) ->
|
.catch (err) ->
|
||||||
utils.mixpanelTrack('Supervisor update failed', error: err)
|
utils.mixpanelTrack('Supervisor update failed', error: err)
|
||||||
# The error here is intentionally not propagated further up the chain,
|
# The error here is intentionally not propagated further up the chain,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user