Fixes to service configuration
restart service does not rebuild automatically, we should add a route for that. we need to figure where to scale services etc if we randomly create containers like that.
This commit is contained in:
41
src/sftp.js
41
src/sftp.js
@@ -1,8 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
exports = module.exports = {
|
||||
startSftp,
|
||||
rebuild
|
||||
start,
|
||||
|
||||
DEFAULT_MEMORY_LIMIT: 256 * 1024 * 1024
|
||||
};
|
||||
|
||||
var apps = require('./apps.js'),
|
||||
@@ -15,36 +16,32 @@ var apps = require('./apps.js'),
|
||||
paths = require('./paths.js'),
|
||||
safe = require('safetydance'),
|
||||
shell = require('./shell.js'),
|
||||
system = require('./system.js'),
|
||||
volumes = require('./volumes.js'),
|
||||
_ = require('underscore');
|
||||
|
||||
function startSftp(existingInfra, callback) {
|
||||
assert.strictEqual(typeof existingInfra, 'object');
|
||||
var gRebuildInProgress = false;
|
||||
function rebuild(serviceConfig, callback) {
|
||||
assert.strictEqual(typeof serviceConfig, 'object');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
rebuild(callback);
|
||||
}
|
||||
|
||||
var rebuildInProgress = false;
|
||||
function rebuild(callback) {
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
if (rebuildInProgress) {
|
||||
if (gRebuildInProgress) {
|
||||
debug('waiting for other rebuild to finish');
|
||||
return setTimeout(function () { rebuild(callback); }, 5000);
|
||||
return setTimeout(function () { rebuild(serviceConfig, callback); }, 5000);
|
||||
}
|
||||
|
||||
rebuildInProgress = true;
|
||||
gRebuildInProgress = true;
|
||||
|
||||
function done(error) {
|
||||
rebuildInProgress = false;
|
||||
gRebuildInProgress = false;
|
||||
callback(error);
|
||||
}
|
||||
|
||||
debug('rebuilding container');
|
||||
|
||||
const tag = infra.images.sftp.tag;
|
||||
const memoryLimit = 256;
|
||||
const memoryLimit = serviceConfig.memoryLimit || exports.DEFAULT_MEMORY_LIMIT;
|
||||
const memory = system.getMemoryAllocation(memoryLimit);
|
||||
const cloudronToken = hat(8 * 128);
|
||||
|
||||
apps.getAll(function (error, result) {
|
||||
@@ -103,8 +100,8 @@ function rebuild(callback) {
|
||||
--log-opt syslog-address=udp://127.0.0.1:2514 \
|
||||
--log-opt syslog-format=rfc5424 \
|
||||
--log-opt tag=sftp \
|
||||
-m ${memoryLimit}m \
|
||||
--memory-swap ${memoryLimit * 2}m \
|
||||
-m ${memory} \
|
||||
--memory-swap ${memoryLimit} \
|
||||
--dns 172.18.0.1 \
|
||||
--dns-search=. \
|
||||
-p 222:22 \
|
||||
@@ -124,3 +121,11 @@ function rebuild(callback) {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function start(existingInfra, serviceConfig, callback) {
|
||||
assert.strictEqual(typeof existingInfra, 'object');
|
||||
assert.strictEqual(typeof serviceConfig, 'object');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
rebuild(serviceConfig, callback);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user