1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2026-02-08 20:50:09 +00:00

Updated service-manager.stop() on Windows to force kill process if stuck in STOP_PENDING

This commit is contained in:
Bryan Roe
2020-06-04 11:27:35 -07:00
parent 5bfd867e86
commit 34908f8a1a
2 changed files with 54 additions and 17 deletions

File diff suppressed because one or more lines are too long

View File

@@ -789,6 +789,8 @@ function serviceManager()
retVal._stopEx = function(s, p)
{
var current = s.status.state;
var pid = s.status.pid;
switch (current)
{
case 'STOPPED':
@@ -802,11 +804,26 @@ function serviceManager()
}
else
{
p._rej('timeout waiting for service to stop');
if (pid > 0)
{
process.kill(pid);
p._res('STOPPED/KILLED');
}
else
{
p._rej('timeout waiting for service to stop');
}
}
break;
default:
p._rej('Unexpected state: ' + current);
if (pid > 0)
{
}
else
{
p._rej('Unexpected state: ' + current);
}
break;
}
}
@@ -815,6 +832,7 @@ function serviceManager()
{
var ret = new promise(function (a, r) { this._res = a; this._rej = r; });
var status = this.status;
var pid = this.status.pid;
if(status.state == 'RUNNING')
{
// Stop Service
@@ -835,6 +853,11 @@ function serviceManager()
ret.timer = setTimeout(this._stopEx, ret._waitTime, this, ret);
}
}
else if (status.state == 'STOP_PENDING' && pid > 0)
{
process.kill(pid);
ret._res('STOPPED/KILLED');
}
else
{
ret._rej('cannot call ' + this.name + '.stop(), when current state is: ' + this.status.state);