UNPKG

mecano

Version:

Common functions for system deployment.

53 lines (50 loc) 1.34 kB
// Generated by CoffeeScript 1.11.1 var discover; module.exports = function(options) { options.log({ message: "Entering service.restart", level: 'DEBUG', module: 'mecano/lib/service/restart' }); if (typeof options.argument === 'string') { if (options.name == null) { options.name = options.argument; } } if (!options.name) { throw Error("Invalid Name: " + (JSON.stringify(options.name))); } options.log({ message: "Restart service " + options.name, level: 'INFO', module: 'mecano/lib/service/restart' }); this.call(discover.loader); return this.call(function() { var cmd; if (options.loader == null) { options.loader = options.store['mecano:service:loader']; } cmd = (function() { switch (options.loader) { case 'systemctl': return "systemctl restart " + options.name; case 'service': return "service " + options.name + " restart"; default: throw Error('Init System not supported'); } })(); return this.execute({ cmd: cmd }, function(err, restarted) { if (err) { throw err; } if (restarted) { return options.store["mecano.service." + options.name + ".status"] = 'started'; } }); }); }; discover = require('../misc/discover');