From 7745338d9e697df335a0e0fd6aa4e2d672fc4da2 Mon Sep 17 00:00:00 2001 From: Bryan Roe Date: Sat, 22 Jun 2019 09:55:33 -0700 Subject: [PATCH] added stop, start, restart, uninstallService for freebsd --- modules/service-manager.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/modules/service-manager.js b/modules/service-manager.js index 4326833..78a3386 100644 --- a/modules/service-manager.js +++ b/modules/service-manager.js @@ -762,6 +762,27 @@ function serviceManager() child.waitExit(); return (parseInt(child.stdout.str.trim()) == process.pid); }; + ret.stop = function stop() + { + var child = require('child_process').execFile('/bin/sh', ['sh']); + child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); }); + child.stdin.write("service " + this.name + " onestop\nexit\n"); + child.waitExit(); + }; + ret.start = function start() + { + var child = require('child_process').execFile('/bin/sh', ['sh']); + child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); }); + child.stdin.write("service " + this.name + " onestart\nexit\n"); + child.waitExit(); + }; + ret.restart = function restart() + { + var child = require('child_process').execFile('/bin/sh', ['sh']); + child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); }); + child.stdin.write("service " + this.name + " onerestart\nexit\n"); + child.waitExit(); + }; return (ret); }; } @@ -1600,6 +1621,18 @@ function serviceManager() throw ('Service: ' + name + ' does not exist'); } } + else if(process.platform == 'freebsd') + { + service.stop(); + require('fs').unlinkSync(service.appLocation()); + require('fs').unlinkSync(service.rc); + try + { + require('fs').rmdirSync('/usr/local/mesh_services/' + name); + } + catch (e) + { } + } } if(process.platform == 'linux') {