mirror of
https://github.com/Jackett/Jackett
synced 2025-02-24 07:10:44 +00:00
Updater: try SIGTERM first
This commit is contained in:
parent
88858022af
commit
aba9e6db47
1 changed files with 26 additions and 3 deletions
|
@ -87,10 +87,33 @@ namespace Jackett.Updater
|
|||
{
|
||||
var proc = Process.GetProcessById(pid);
|
||||
logger.Info("Killing process " + proc.Id);
|
||||
proc.Kill();
|
||||
var exited = proc.WaitForExit(5000);
|
||||
|
||||
// try to kill gracefully (on unix) first, see #3692
|
||||
var exited = false;
|
||||
if (Environment.OSVersion.Platform == PlatformID.Unix)
|
||||
{
|
||||
try
|
||||
{
|
||||
var startInfo = new ProcessStartInfo();
|
||||
startInfo.Arguments = "-15 " + pid;
|
||||
startInfo.FileName = "kill";
|
||||
Process.Start(startInfo);
|
||||
exited = proc.WaitForExit(5000);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.Error(e, "Error while sending SIGTERM to " + pid.ToString());
|
||||
}
|
||||
if (!exited)
|
||||
logger.Info("Process " + pid.ToString() + " didn't exit within 5 seconds after a SIGTERM");
|
||||
}
|
||||
if (!exited)
|
||||
logger.Info("Process " + pid.ToString() + " didn't exit within 5 seconds");
|
||||
{
|
||||
proc.Kill(); // send SIGKILL
|
||||
}
|
||||
exited = proc.WaitForExit(5000);
|
||||
if (!exited)
|
||||
logger.Info("Process " + pid.ToString() + " didn't exit within 5 seconds after a SIGKILL");
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue