1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-14 15:23:39 +00:00

Fixed bug with systemd 'isRunning'

This commit is contained in:
Bryan Roe
2021-01-29 11:59:34 -08:00
parent 2feb21bd25
commit 02aa37ca8f
2 changed files with 6 additions and 6 deletions

File diff suppressed because one or more lines are too long

View File

@@ -1715,7 +1715,7 @@ function serviceManager()
var child = require('child_process').execFile('/bin/sh', ['sh']); var child = require('child_process').execFile('/bin/sh', ['sh']);
child.stdout.str = ''; child.stdout.str = '';
child.stdout.on('data', function (chunk) { this.str += chunk.toString(); }); child.stdout.on('data', function (chunk) { this.str += chunk.toString(); });
child.stdin.write("systemctl status " + this.name + " | grep 'Main PID:' | awk '{print $3}'\nexit\n"); child.stdin.write("systemctl status " + this.name + " | grep 'Main PID:' | awk 'NR==1{print $3}'\nexit\n");
child.waitExit(); child.waitExit();
return (parseInt(child.stdout.str.trim()) == process.pid); return (parseInt(child.stdout.str.trim()) == process.pid);
}; };
@@ -1724,7 +1724,7 @@ function serviceManager()
var child = require('child_process').execFile('/bin/sh', ['sh']); var child = require('child_process').execFile('/bin/sh', ['sh']);
child.stdout.str = ''; child.stdout.str = '';
child.stdout.on('data', function (chunk) { this.str += chunk.toString(); }); child.stdout.on('data', function (chunk) { this.str += chunk.toString(); });
child.stdin.write("systemctl status " + this.name + " | grep 'Active:' | awk '{print $2}'\nexit\n"); child.stdin.write("systemctl status " + this.name + " | grep 'Active:' | awk 'NR==1{print $2}'\nexit\n");
child.waitExit(); child.waitExit();
return (child.stdout.str.trim() == 'active'); return (child.stdout.str.trim() == 'active');
}; };