1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-25 12:43:30 +00:00

1. Fixed process.kill() on windows to wait to complete

2. Updated self update on windows to handle stale processes
This commit is contained in:
Bryan Roe
2020-05-20 21:10:02 -07:00
parent 79e7b74598
commit 70979ad761
4 changed files with 79 additions and 12 deletions

View File

@@ -406,4 +406,52 @@ module.exports =
{
fullInstall: fullInstall,
fullUninstall: fullUninstall
};
};
if (process.platform == 'win32')
{
function win_update()
{
var fini = setTimeout(function ()
{
// If this hits, it's becuase something went wrong... So just abort
process._exit();
}, 20000);
var updateLocation = process.argv[1].substring(8);
var service = null;
var serviceLocation = "";
service = require('service-manager').manager.getService('Mesh Agent');
serviceLocation = service.appLocation();
var t = setTimeout(function ()
{
service.stop().finally(function ()
{
require('process-manager').enumerateProcesses().then(function (proc)
{
for (var p in proc)
{
if (proc[p].path == serviceLocation)
{
process.kill(proc[p].pid);
}
}
try
{
require('fs').copyFileSync(process.execPath, updateLocation);
}
catch (ce)
{
}
service.start();
process._exit();
});
});
}, 3000);
}
module.exports.update = win_update;
}