Fixed: Removal of previous service

Co-Authored-By: Mark McDowall <markus101@users.noreply.github.com>
pull/59/head
Qstick 4 years ago
parent e1bddd8784
commit a14c0d2388

@ -62,9 +62,9 @@ Name: "{userstartup}\{#AppName}"; Filename: "{app}\Prowlarr.exe"; WorkingDir: "{
Name: "{app}"; Type: filesandordirs
[Run]
Filename: "{app}\Prowlarr.Console.exe"; StatusMsg: "Removing previous Windows Service"; Parameters: "/u"; Flags: runhidden waituntilterminated;
Filename: "{app}\Prowlarr.Console.exe"; Description: "Enable Access from Other Devices"; StatusMsg: "Enabling Remote access"; Parameters: "/registerurl"; Flags: postinstall runascurrentuser runhidden waituntilterminated; Tasks: startupShortcut none;
Filename: "{app}\Prowlarr.Console.exe"; StatusMsg: "Installing Windows Service"; Parameters: "/i"; Flags: runhidden waituntilterminated; Tasks: windowsService
Filename: "{app}\Prowlarr.Console.exe"; StatusMsg: "Removing previous Windows Service"; Parameters: "/u /exitimmediately"; Flags: runhidden waituntilterminated;
Filename: "{app}\Prowlarr.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}\Prowlarr.Console.exe"; StatusMsg: "Installing Windows Service"; Parameters: "/i /exitimmediately"; Flags: runhidden waituntilterminated; Tasks: windowsService
Filename: "{app}\Prowlarr.exe"; Description: "Open Prowlarr Web UI"; Flags: postinstall skipifsilent nowait; Tasks: windowsService;
Filename: "{app}\Prowlarr.exe"; Description: "Start Prowlarr"; Flags: postinstall skipifsilent nowait; Tasks: startupShortcut none;

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
namespace NzbDrone.Common.EnvironmentInfo
{
@ -25,6 +25,7 @@ namespace NzbDrone.Common.EnvironmentInfo
public const string RESTART = "restart";
public const string REGISTER_URL = "registerurl";
public const string NO_SINGLE_INSTANCE_CHECK = "nosingleinstancecheck";
public const string EXIT_IMMEDIATELY = "exitimmediately";
public StartupContext(params string[] args)
{
@ -55,6 +56,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,9 +25,11 @@ namespace NzbDrone.Console
public static void Main(string[] args)
{
StartupContext startupArgs = null;
try
{
var startupArgs = new StartupContext(args);
startupArgs = new StartupContext(args);
try
{
NzbDroneLogger.Register(startupArgs, false, true);
@ -45,14 +47,14 @@ 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 Prowlarr is already running another application is using the same port (default: 9696) or the user has insufficient permissions");
Exit(ExitCodes.RecoverableFailure);
Exit(ExitCodes.RecoverableFailure, startupArgs);
}
catch (IOException ex)
{
@ -61,7 +63,7 @@ namespace NzbDrone.Console
System.Console.WriteLine("");
System.Console.WriteLine("");
Logger.Fatal(ex.Message + " This can happen if another instance of Prowlarr is already running another application is using the same port (default: 9696) or the user has insufficient permissions");
Exit(ExitCodes.RecoverableFailure);
Exit(ExitCodes.RecoverableFailure, startupArgs);
}
else
{
@ -73,22 +75,22 @@ namespace NzbDrone.Console
System.Console.WriteLine("");
System.Console.WriteLine("");
Logger.Fatal(ex, "EPIC FAIL!");
Exit(ExitCodes.Normal);
Exit(ExitCodes.Normal, startupArgs);
}
catch (Exception ex)
{
System.Console.WriteLine("");
System.Console.WriteLine("");
Logger.Fatal(ex, "EPIC FAIL!");
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();
@ -100,6 +102,13 @@ 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…
Cancel
Save