|
|
@ -14,12 +14,14 @@ namespace NzbDrone.Host
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private readonly IRuntimeInfo _runtimeInfo;
|
|
|
|
private readonly IRuntimeInfo _runtimeInfo;
|
|
|
|
private readonly IProcessProvider _processProvider;
|
|
|
|
private readonly IProcessProvider _processProvider;
|
|
|
|
|
|
|
|
private readonly IStartupContext _startupContext;
|
|
|
|
private readonly Logger _logger;
|
|
|
|
private readonly Logger _logger;
|
|
|
|
|
|
|
|
|
|
|
|
public SpinService(IRuntimeInfo runtimeInfo, IProcessProvider processProvider, Logger logger)
|
|
|
|
public SpinService(IRuntimeInfo runtimeInfo, IProcessProvider processProvider, IStartupContext startupContext, Logger logger)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_runtimeInfo = runtimeInfo;
|
|
|
|
_runtimeInfo = runtimeInfo;
|
|
|
|
_processProvider = processProvider;
|
|
|
|
_processProvider = processProvider;
|
|
|
|
|
|
|
|
_startupContext = startupContext;
|
|
|
|
_logger = logger;
|
|
|
|
_logger = logger;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -30,13 +32,29 @@ namespace NzbDrone.Host
|
|
|
|
Thread.Sleep(1000);
|
|
|
|
Thread.Sleep(1000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_logger.Debug("wait loop was terminated.");
|
|
|
|
_logger.Debug("Wait loop was terminated.");
|
|
|
|
|
|
|
|
|
|
|
|
if (_runtimeInfo.RestartPending)
|
|
|
|
if (_runtimeInfo.RestartPending)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_logger.Info("attemptig restart.");
|
|
|
|
var restartArgs = GetRestartArgs();
|
|
|
|
_processProvider.SpawnNewProcess(_runtimeInfo.ExecutingApplication, "--restart --nobrowser");
|
|
|
|
|
|
|
|
|
|
|
|
_logger.Info("Attempting restart with arguments: {0}", restartArgs);
|
|
|
|
|
|
|
|
_processProvider.SpawnNewProcess(_runtimeInfo.ExecutingApplication, restartArgs);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private string GetRestartArgs()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var args = _startupContext.PreservedArguments;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
args += " /restart";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!args.Contains("/nobrowser"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
args += " /nobrowser";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return args;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|