services: simplify startup logic
This commit is contained in:
+6
-13
@@ -2,7 +2,6 @@
|
||||
|
||||
exports = module.exports = {
|
||||
start,
|
||||
rebuild,
|
||||
|
||||
DEFAULT_MEMORY_LIMIT: 256 * 1024 * 1024
|
||||
};
|
||||
@@ -13,19 +12,20 @@ const apps = require('./apps.js'),
|
||||
debug = require('debug')('box:sftp'),
|
||||
hat = require('./hat.js'),
|
||||
infra = require('./infra_version.js'),
|
||||
path = require('path'),
|
||||
paths = require('./paths.js'),
|
||||
safe = require('safetydance'),
|
||||
settings = require('./settings.js'),
|
||||
shell = require('./shell.js'),
|
||||
system = require('./system.js'),
|
||||
volumes = require('./volumes.js');
|
||||
|
||||
async function rebuild(serviceConfig, options) {
|
||||
assert.strictEqual(typeof serviceConfig, 'object');
|
||||
assert.strictEqual(typeof options, 'object');
|
||||
async function start(existingInfra) {
|
||||
assert.strictEqual(typeof existingInfra, 'object');
|
||||
|
||||
debug('rebuilding container');
|
||||
debug('start: re-creating container');
|
||||
|
||||
const servicesConfig = await settings.getServicesConfig();
|
||||
const serviceConfig = servicesConfig['sftp'] || {};
|
||||
const tag = infra.images.sftp.tag;
|
||||
const memoryLimit = serviceConfig.memoryLimit || exports.DEFAULT_MEMORY_LIMIT;
|
||||
const memory = system.getMemoryAllocation(memoryLimit);
|
||||
@@ -95,10 +95,3 @@ async function rebuild(serviceConfig, options) {
|
||||
await shell.promises.exec('removeSftp', 'docker rm -f sftp || true');
|
||||
await shell.promises.exec('startSftp', cmd);
|
||||
}
|
||||
|
||||
async function start(existingInfra, serviceConfig) {
|
||||
assert.strictEqual(typeof existingInfra, 'object');
|
||||
assert.strictEqual(typeof serviceConfig, 'object');
|
||||
|
||||
await rebuild(serviceConfig, { force: true }); // force rebuild when infra changed
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user