Hidden startup, shutodwn and restart

New: Run without console window by default
New: Added NzbDrone.Console to run with console window
New: Shutdown from UI
New: Restart from UI
This commit is contained in:
Mark McDowall
2013-01-06 00:11:14 -08:00
parent 17d9d0cc4f
commit 125703a2fa
29 changed files with 504 additions and 98 deletions
+1
View File
@@ -20,6 +20,7 @@ namespace NzbDrone.Common
Console.WriteLine(" Commands:");
Console.WriteLine(" /i Install the application as a Windows Service ({0}).", ServiceProvider.NZBDRONE_SERVICE_NAME);
Console.WriteLine(" /u Uninstall already installed Windows Service ({0}).", ServiceProvider.NZBDRONE_SERVICE_NAME);
Console.WriteLine(" /s Run NzbDrone without a Console Window.");
Console.WriteLine(" <No Arguments> Run application in console mode.");
}
+2 -2
View File
@@ -74,7 +74,7 @@ namespace NzbDrone.Common
if (!string.IsNullOrWhiteSpace(applicationPath))
return applicationPath;
applicationPath = CrawlToRoot(NzbDronePathFromEnviroment);
applicationPath = CrawlToRoot(NzbDronePathFromEnvironment);
if (!string.IsNullOrWhiteSpace(applicationPath))
return applicationPath;
@@ -146,7 +146,7 @@ namespace NzbDrone.Common
}
}
public virtual string NzbDronePathFromEnviroment
public virtual string NzbDronePathFromEnvironment
{
get
{
+7 -4
View File
@@ -51,7 +51,6 @@ namespace NzbDrone.Common
startInfo.RedirectStandardError = true;
startInfo.CreateNoWindow = true;
startInfo.EnvironmentVariables[EnvironmentProvider.NZBDRONE_PATH] = _environmentProvider.ApplicationPath;
startInfo.EnvironmentVariables[EnvironmentProvider.NZBDRONE_PID] = Process.GetCurrentProcess().Id.ToString();
@@ -74,6 +73,9 @@ namespace NzbDrone.Common
iisProcess.BeginOutputReadLine();
ServerStarted = true;
iisProcess.EnableRaisingEvents = true;
iisProcess.Exited += IIS_EXITED;
}
private static void OnErrorDataReceived(object sender, DataReceivedEventArgs e)
@@ -84,7 +86,6 @@ namespace NzbDrone.Common
IISLogger.Error(e.Data);
}
public void RestartServer()
{
ServerStarted = false;
@@ -93,7 +94,6 @@ namespace NzbDrone.Common
StartServer();
}
public virtual void StopServer()
{
_processProvider.Kill(IISProcessId);
@@ -114,6 +114,10 @@ namespace NzbDrone.Common
}
}
public void IIS_EXITED(object obj, EventArgs args)
{
RestartServer();
}
private void OnOutputDataReceived(object s, DataReceivedEventArgs e)
{
@@ -123,6 +127,5 @@ namespace NzbDrone.Common
Console.WriteLine(e.Data);
}
}
}
+7 -2
View File
@@ -9,11 +9,11 @@ namespace NzbDrone.Common
private const string APP_DATA = "App_Data\\";
public const string IIS_FOLDER = "IISExpress";
public const string IIS_EXE = "iisexpress.exe";
private const string LOG_CONFIG_FILE = "log.config";
private const string APP_CONFIG_FILE = "config.xml";
public const string NZBDRONE_EXE = "NzbDrone.exe";
public const string NZBDRONE_DB_FILE = "nzbdrone.sdf";
public const string LOG_DB_FILE = "log.sdf";
@@ -156,5 +156,10 @@ namespace NzbDrone.Common
{
return Path.Combine(environmentProvider.GetAppDataPath(), BACKUP_ZIP_FILE);
}
public static string GetNzbDroneExe(this EnvironmentProvider environmentProvider)
{
return Path.Combine(environmentProvider.ApplicationPath, NZBDRONE_EXE);
}
}
}
+1 -1
View File
@@ -11,6 +11,7 @@ namespace NzbDrone.Common
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public static readonly string NzbDroneProccessName = "NzbDrone";
public static readonly string NzbDroneConsoleProccessName = "NzbDrone.Console";
public virtual ProcessInfo GetCurrentProcess()
{
@@ -107,6 +108,5 @@ namespace NzbDrone.Common
Name = process.ProcessName
};
}
}
}