mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-20 21:43:33 -07:00
fixed NzbDrone using 100% cpu when console not available.
This commit is contained in:
parent
e377e02db4
commit
75a46a3abe
9 changed files with 39 additions and 31 deletions
|
@ -21,6 +21,7 @@ namespace NzbDrone.Common
|
|||
bool Exists(string processName);
|
||||
ProcessPriorityClass GetCurrentProcessPriority();
|
||||
Process Start(string path, string args = null, Action<string> onOutputDataReceived = null, Action<string> onErrorDataReceived = null);
|
||||
Process SpawnNewProcess(string path, string args = null);
|
||||
}
|
||||
|
||||
public class ProcessProvider : IProcessProvider
|
||||
|
@ -86,6 +87,8 @@ namespace NzbDrone.Common
|
|||
process.Start();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Process Start(string path, string args = null, Action<string> onOutputDataReceived = null, Action<string> onErrorDataReceived = null)
|
||||
{
|
||||
|
||||
|
@ -147,6 +150,27 @@ namespace NzbDrone.Common
|
|||
return process;
|
||||
}
|
||||
|
||||
public Process SpawnNewProcess(string path, string args = null)
|
||||
{
|
||||
if (OsInfo.IsMono && path.EndsWith(".exe", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
args = path + " " + args;
|
||||
path = "mono";
|
||||
}
|
||||
|
||||
Logger.Info("Starting {0} {1}", path, args);
|
||||
|
||||
var startInfo = new ProcessStartInfo(path, args);
|
||||
var process = new Process
|
||||
{
|
||||
StartInfo = startInfo
|
||||
};
|
||||
|
||||
process.Start();
|
||||
|
||||
return process;
|
||||
}
|
||||
|
||||
public void WaitForExit(Process process)
|
||||
{
|
||||
Logger.Trace("Waiting for process {0} to exit.", process.ProcessName);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue