mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-02-21 02:01:35 +00:00
Make handover-complete an alternative to the resin-kill-me file
Also fixes the handover wait (since the service interface for it was missing). We add some logging to this process too. Change-type: minor Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
This commit is contained in:
parent
8003f25c3d
commit
802025c01f
@ -227,16 +227,23 @@ module.exports = class ServiceManager extends EventEmitter
|
||||
timeout = checkInt(timeout, positive: true) ? 60000
|
||||
deadline = Date.now() + timeout
|
||||
|
||||
killmePath = service.killmeFullPathOnHost()
|
||||
handoverCompletePaths = service.handoverCompleteFullPathsOnHost()
|
||||
|
||||
wait = ->
|
||||
fs.statAsync(killmePath)
|
||||
.then ->
|
||||
fs.unlinkAsync(killmePath).catch(_.noop)
|
||||
.catch (err) ->
|
||||
Promise.any _.map handoverCompletePaths, (file) ->
|
||||
fs.statAsync(file)
|
||||
.then ->
|
||||
fs.unlinkAsync(handoverCompletePaths).catch(_.noop)
|
||||
.catch ->
|
||||
if Date.now() < deadline
|
||||
Promise.delay(pollInterval).then(wait)
|
||||
else
|
||||
console.log('Handover timeout has passed, assuming handover was completed')
|
||||
|
||||
console.log('Waiting for handover to be completed')
|
||||
wait()
|
||||
.then ->
|
||||
console.log('Handover complete')
|
||||
|
||||
prepareForHandover: (service) =>
|
||||
@get(service)
|
||||
|
@ -19,6 +19,7 @@ import * as ComposeUtils from './utils';
|
||||
|
||||
import * as updateLock from '../lib/update-lock';
|
||||
import { sanitiseComposeConfig } from './sanitise';
|
||||
import * as constants from '../lib/constants';
|
||||
|
||||
export class Service {
|
||||
|
||||
@ -655,6 +656,17 @@ export class Service {
|
||||
return _.reject(validVolumes, _.isNil);
|
||||
}
|
||||
|
||||
public handoverCompleteFullPathsOnHost(): string[] {
|
||||
return [
|
||||
path.join(handoverCompletePathOnHost(), 'handover-complete'),
|
||||
path.join(handoverCompletePathOnHost(), 'resin-kill-me'),
|
||||
];
|
||||
}
|
||||
|
||||
private handoverCompletePathOnHost(): string {
|
||||
return path.join(constants.rootMountPoint, updateLock.lockPath(this.appId, this.serviceName));
|
||||
}
|
||||
|
||||
private getBindsAndVolumes(): {
|
||||
binds: string[],
|
||||
volumes: { [volName: string]: { } }
|
||||
|
Loading…
x
Reference in New Issue
Block a user