mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-10 05:13:38 +00:00
Added 'isLoaded' and 'load' helper on MacOS
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -383,6 +383,7 @@ function serviceManager()
|
||||
return (child.stdout.str.trim());
|
||||
})()
|
||||
});
|
||||
|
||||
if (!ret.alias)
|
||||
{
|
||||
Object.defineProperty(ret, 'alias', {
|
||||
@@ -406,6 +407,23 @@ function serviceManager()
|
||||
child.waitExit();
|
||||
return (parseInt(child.stdout.str.trim()));
|
||||
};
|
||||
ret.isLoaded = function isLoaded()
|
||||
{
|
||||
var child = require('child_process').execFile('/bin/sh', ['sh']);
|
||||
child.stdout.str = '';
|
||||
child.stdout.on('data', function (chunk) { this.str += chunk.toString(); });
|
||||
child.stdin.write("launchctl list | grep '" + this.alias + "' | awk '{ if($3==\"" + this.alias + "\"){print $1;}}'\nexit\n");
|
||||
child.waitExit();
|
||||
return (child.stdout.str.trim() != '');
|
||||
};
|
||||
ret.load = function load()
|
||||
{
|
||||
var child = require('child_process').execFile('/bin/sh', ['sh']);
|
||||
child.stdout.str = '';
|
||||
child.stdout.on('data', function (chunk) { this.str += chunk.toString(); });
|
||||
child.stdin.write('launchctl load ' + this.plist + '\nexit\n');
|
||||
child.waitExit();
|
||||
};
|
||||
ret.isRunning = function isRunning()
|
||||
{
|
||||
return (this.getPID() > 0);
|
||||
|
||||
Reference in New Issue
Block a user