stop app now stops it's services as well
This commit is contained in:
@@ -7,6 +7,9 @@ exports = module.exports = {
|
||||
getServiceLogs: getServiceLogs,
|
||||
restartService: restartService,
|
||||
|
||||
startAppServices,
|
||||
stopAppServices,
|
||||
|
||||
startServices: startServices,
|
||||
updateServiceConfig: updateServiceConfig,
|
||||
|
||||
@@ -213,6 +216,8 @@ const SERVICES = {
|
||||
const APP_SERVICES = {
|
||||
redis: {
|
||||
status: (instance, done) => containerStatus(`redis-${instance}`, 'CLOUDRON_REDIS_TOKEN', done),
|
||||
start: (instance, done) => docker.startContainer(`redis-${instance}`, done),
|
||||
stop: (instance, done) => docker.stopContainer(`redis-${instance}`, done),
|
||||
restart: (instance, done) => restartContainer(`redis-${instance}`, done),
|
||||
defaultMemoryLimit: 150 * 1024 * 1024
|
||||
}
|
||||
@@ -554,6 +559,42 @@ function restartService(id, callback) {
|
||||
}
|
||||
}
|
||||
|
||||
// in the future, we can refcount and lazy start global services
|
||||
function startAppServices(app, callback) {
|
||||
assert.strictEqual(typeof app, 'object');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
const instance = app.id;
|
||||
async.eachSeries(Object.keys(app.manifest.addons || {}), function (addon, iteratorDone) {
|
||||
if (!(addon in APP_SERVICES)) return iteratorDone();
|
||||
|
||||
APP_SERVICES[addon].start(instance, function (error) { // assume addons name is service name
|
||||
// error ignored because we don't want "start app" to error. use can fix it from Services
|
||||
if (error) debug(`startAppServices: ${addon}:${instance}`, error);
|
||||
|
||||
iteratorDone();
|
||||
});
|
||||
}, callback);
|
||||
}
|
||||
|
||||
// in the future, we can refcount and stop global services as well
|
||||
function stopAppServices(app, callback) {
|
||||
assert.strictEqual(typeof app, 'object');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
const instance = app.id;
|
||||
async.eachSeries(Object.keys(app.manifest.addons || {}), function (addon, iteratorDone) {
|
||||
if (!(addon in APP_SERVICES)) return iteratorDone();
|
||||
|
||||
APP_SERVICES[addon].stop(instance, function (error) { // assume addons name is service name
|
||||
// error ignored because we don't want "start app" to error. use can fix it from Services
|
||||
if (error) debug(`stopAppServices: ${addon}:${instance}`, error);
|
||||
|
||||
iteratorDone();
|
||||
});
|
||||
}, callback);
|
||||
}
|
||||
|
||||
function waitForContainer(containerName, tokenEnvName, callback) {
|
||||
assert.strictEqual(typeof containerName, 'string');
|
||||
assert.strictEqual(typeof tokenEnvName, 'string');
|
||||
|
||||
Reference in New Issue
Block a user