'use strict'; exports = module.exports = { start, DEFAULT_MEMORY_LIMIT: 256 * 1024 * 1024 }; var assert = require('assert'), async = require('async'), infra = require('./infra_version.js'), paths = require('./paths.js'), shell = require('./shell.js'), system = require('./system.js'); function start(existingInfra, serviceConfig, callback) { assert.strictEqual(typeof existingInfra, 'object'); assert.strictEqual(typeof serviceConfig, 'object'); assert.strictEqual(typeof callback, 'function'); const tag = infra.images.graphite.tag; const memoryLimit = serviceConfig.memoryLimit || exports.DEFAULT_MEMORY_LIMIT; const memory = system.getMemoryAllocation(memoryLimit); const cmd = `docker run --restart=always -d --name="graphite" \ --hostname graphite \ --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 \ -m ${memory} \ --memory-swap ${memoryLimit} \ --dns 172.18.0.1 \ --dns-search=. \ -p 127.0.0.1:2003:2003 \ -p 127.0.0.1:2004:2004 \ -p 127.0.0.1:8417:8000 \ -v "${paths.PLATFORM_DATA_DIR}/graphite:/var/lib/graphite" \ --label isCloudronManaged=true \ --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); }