Files
cloudron-box/src/graphite.js
T

50 lines
1.8 KiB
JavaScript
Raw Normal View History

2018-10-16 14:07:41 -07:00
'use strict';
exports = module.exports = {
2021-01-21 12:53:38 -08:00
start,
DEFAULT_MEMORY_LIMIT: 256 * 1024 * 1024
2018-10-16 14:07:41 -07:00
};
var assert = require('assert'),
async = require('async'),
2018-10-16 14:07:41 -07:00
infra = require('./infra_version.js'),
paths = require('./paths.js'),
2021-01-21 12:53:38 -08:00
shell = require('./shell.js'),
system = require('./system.js');
2018-10-16 14:07:41 -07:00
2021-01-21 12:53:38 -08:00
function start(existingInfra, serviceConfig, callback) {
2018-10-16 14:07:41 -07:00
assert.strictEqual(typeof existingInfra, 'object');
2021-01-21 12:53:38 -08:00
assert.strictEqual(typeof serviceConfig, 'object');
2018-10-16 14:07:41 -07:00
assert.strictEqual(typeof callback, 'function');
const tag = infra.images.graphite.tag;
2021-01-21 12:53:38 -08:00
const memoryLimit = serviceConfig.memoryLimit || exports.DEFAULT_MEMORY_LIMIT;
const memory = system.getMemoryAllocation(memoryLimit);
2018-10-16 14:07:41 -07:00
const cmd = `docker run --restart=always -d --name="graphite" \
2019-06-01 09:36:35 -07:00
--hostname graphite \
2018-10-16 14:07:41 -07:00
--net cloudron \
--net-alias graphite \
--log-driver syslog \
--log-opt syslog-address=udp://127.0.0.1:2514 \
--log-opt syslog-format=rfc5424 \
--log-opt tag=graphite \
2021-01-21 12:53:38 -08:00
-m ${memory} \
--memory-swap ${memoryLimit} \
2020-11-25 10:02:43 -08:00
--dns 172.18.0.1 \
--dns-search=. \
2018-10-16 14:07:41 -07:00
-p 127.0.0.1:2003:2003 \
-p 127.0.0.1:2004:2004 \
2018-11-16 19:23:09 -08:00
-p 127.0.0.1:8417:8000 \
2021-03-18 17:39:46 -07:00
-v "${paths.PLATFORM_DATA_DIR}/graphite:/var/lib/graphite" \
--label isCloudronManaged=true \
2018-10-16 14:07:41 -07:00
--read-only -v /tmp -v /run "${tag}"`;
async.series([
shell.exec.bind(null, 'stopGraphite', 'docker stop graphite || true'),
shell.exec.bind(null, 'removeGraphite', 'docker rm -f graphite || true'),
shell.exec.bind(null, 'startGraphite', cmd)
], callback);
2018-10-16 14:07:41 -07:00
}