mirror of
https://github.com/Sonarr/Sonarr.git
synced 2025-02-02 11:34:39 +02:00
Fixed: Removal of previous service
This commit is contained in:
parent
e9818b9982
commit
cd28af98ee
@ -63,9 +63,9 @@ Name: "{commonappdata}\NzbDrone\bin"; Type: filesandordirs
|
||||
Name: "{app}"; Type: filesandordirs
|
||||
|
||||
[Run]
|
||||
Filename: "{app}\Sonarr.Console.exe"; StatusMsg: "Removing previous Windows Service"; Parameters: "/u"; Flags: runhidden waituntilterminated;
|
||||
Filename: "{app}\Sonarr.Console.exe"; Description: "Enable Access from Other Devices"; StatusMsg: "Enabling Remote access"; Parameters: "/registerurl"; Flags: postinstall runascurrentuser runhidden waituntilterminated; Tasks: startupShortcut none;
|
||||
Filename: "{app}\Sonarr.Console.exe"; StatusMsg: "Installing Windows Service"; Parameters: "/i"; Flags: runhidden waituntilterminated; Tasks: windowsService
|
||||
Filename: "{app}\Sonarr.Console.exe"; StatusMsg: "Removing previous Windows Service"; Parameters: "/u /exitimmediately"; Flags: runhidden waituntilterminated;
|
||||
Filename: "{app}\Sonarr.Console.exe"; Description: "Enable Access from Other Devices"; StatusMsg: "Enabling Remote access"; Parameters: "/registerurl /exitimmediately"; Flags: postinstall runascurrentuser runhidden waituntilterminated; Tasks: startupShortcut none;
|
||||
Filename: "{app}\Sonarr.Console.exe"; StatusMsg: "Installing Windows Service"; Parameters: "/i /exitimmediately"; Flags: runhidden waituntilterminated; Tasks: windowsService
|
||||
Filename: "{app}\Sonarr.exe"; Description: "Open Sonarr Web UI"; Flags: postinstall skipifsilent nowait; Tasks: windowsService;
|
||||
Filename: "{app}\Sonarr.exe"; Description: "Start Sonarr"; Flags: postinstall skipifsilent nowait; Tasks: startupShortcut none;
|
||||
|
||||
|
@ -24,6 +24,7 @@ namespace NzbDrone.Common.EnvironmentInfo
|
||||
public const string TERMINATE = "terminateexisting";
|
||||
public const string RESTART = "restart";
|
||||
public const string REGISTER_URL = "registerurl";
|
||||
public const string EXIT_IMMEDIATELY = "exitimmediately";
|
||||
|
||||
public StartupContext(params string[] args)
|
||||
{
|
||||
@ -54,6 +55,7 @@ namespace NzbDrone.Common.EnvironmentInfo
|
||||
public bool InstallService => Flags.Contains(INSTALL_SERVICE);
|
||||
public bool UninstallService => Flags.Contains(UNINSTALL_SERVICE);
|
||||
public bool RegisterUrl => Flags.Contains(REGISTER_URL);
|
||||
public bool ExitImmediately => Flags.Contains(EXIT_IMMEDIATELY);
|
||||
|
||||
public string PreservedArguments
|
||||
{
|
||||
|
@ -25,10 +25,11 @@ namespace NzbDrone.Console
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
RuntimePatcher.Initialize();
|
||||
StartupContext startupArgs = null;
|
||||
|
||||
try
|
||||
{
|
||||
var startupArgs = new StartupContext(args);
|
||||
startupArgs = new StartupContext(args);
|
||||
try
|
||||
{
|
||||
NzbDroneLogger.Register(startupArgs, false, true);
|
||||
@ -45,21 +46,21 @@ namespace NzbDrone.Console
|
||||
System.Console.WriteLine("");
|
||||
System.Console.WriteLine("");
|
||||
Logger.Fatal(ex, "EPIC FAIL!");
|
||||
Exit(ExitCodes.NonRecoverableFailure);
|
||||
Exit(ExitCodes.NonRecoverableFailure, startupArgs);
|
||||
}
|
||||
catch (SocketException ex)
|
||||
{
|
||||
System.Console.WriteLine("");
|
||||
System.Console.WriteLine("");
|
||||
Logger.Fatal(ex.Message + ". This can happen if another instance of Sonarr is already running another application is using the same port (default: 8989) or the user has insufficient permissions");
|
||||
Exit(ExitCodes.RecoverableFailure);
|
||||
Exit(ExitCodes.RecoverableFailure, startupArgs);
|
||||
}
|
||||
catch (RemoteAccessException ex)
|
||||
{
|
||||
System.Console.WriteLine("");
|
||||
System.Console.WriteLine("");
|
||||
Logger.Fatal(ex, "EPIC FAIL!");
|
||||
Exit(ExitCodes.Normal);
|
||||
Exit(ExitCodes.Normal, startupArgs);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -67,15 +68,15 @@ namespace NzbDrone.Console
|
||||
System.Console.WriteLine("");
|
||||
Logger.Fatal(ex, "EPIC FAIL!");
|
||||
System.Console.WriteLine("EPIC FAIL! " + ex.ToString());
|
||||
Exit(ExitCodes.UnknownFailure);
|
||||
Exit(ExitCodes.UnknownFailure, startupArgs);
|
||||
}
|
||||
|
||||
Logger.Info("Exiting main.");
|
||||
|
||||
Exit(ExitCodes.Normal);
|
||||
Exit(ExitCodes.Normal, startupArgs);
|
||||
}
|
||||
|
||||
private static void Exit(ExitCodes exitCode)
|
||||
private static void Exit(ExitCodes exitCode, StartupContext startupArgs)
|
||||
{
|
||||
LogManager.Shutdown();
|
||||
|
||||
@ -87,6 +88,15 @@ namespace NzbDrone.Console
|
||||
|
||||
if (exitCode == ExitCodes.NonRecoverableFailure)
|
||||
{
|
||||
|
||||
|
||||
if (startupArgs?.ExitImmediately == true)
|
||||
{
|
||||
System.Console.WriteLine("Non-recoverable failure, but set to exit immediately");
|
||||
|
||||
Environment.Exit((int)exitCode);
|
||||
}
|
||||
|
||||
System.Console.WriteLine("Non-recoverable failure, waiting for user intervention...");
|
||||
for (int i = 0; i < 3600; i++)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user