|
|
|
@ -72,69 +72,71 @@ namespace MediaBrowser.ServerApplication
|
|
|
|
|
|
|
|
|
|
var appPaths = CreateApplicationPaths(ApplicationPath, IsRunningAsService);
|
|
|
|
|
|
|
|
|
|
var logManager = new SimpleLogManager(appPaths.LogDirectoryPath, "server");
|
|
|
|
|
logManager.ReloadLogger(LogSeverity.Debug);
|
|
|
|
|
logManager.AddConsoleOutput();
|
|
|
|
|
using (var logManager = new SimpleLogManager(appPaths.LogDirectoryPath, "server"))
|
|
|
|
|
{
|
|
|
|
|
logManager.ReloadLogger(LogSeverity.Debug);
|
|
|
|
|
logManager.AddConsoleOutput();
|
|
|
|
|
|
|
|
|
|
var logger = _logger = logManager.GetLogger("Main");
|
|
|
|
|
var logger = _logger = logManager.GetLogger("Main");
|
|
|
|
|
|
|
|
|
|
ApplicationHost.LogEnvironmentInfo(logger, appPaths, true);
|
|
|
|
|
ApplicationHost.LogEnvironmentInfo(logger, appPaths, true);
|
|
|
|
|
|
|
|
|
|
// Install directly
|
|
|
|
|
if (options.ContainsOption("-installservice"))
|
|
|
|
|
{
|
|
|
|
|
logger.Info("Performing service installation");
|
|
|
|
|
InstallService(ApplicationPath, logger);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// Install directly
|
|
|
|
|
if (options.ContainsOption("-installservice"))
|
|
|
|
|
{
|
|
|
|
|
logger.Info("Performing service installation");
|
|
|
|
|
InstallService(ApplicationPath, logger);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Restart with admin rights, then install
|
|
|
|
|
if (options.ContainsOption("-installserviceasadmin"))
|
|
|
|
|
{
|
|
|
|
|
logger.Info("Performing service installation");
|
|
|
|
|
RunServiceInstallation(ApplicationPath);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// Restart with admin rights, then install
|
|
|
|
|
if (options.ContainsOption("-installserviceasadmin"))
|
|
|
|
|
{
|
|
|
|
|
logger.Info("Performing service installation");
|
|
|
|
|
RunServiceInstallation(ApplicationPath);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Uninstall directly
|
|
|
|
|
if (options.ContainsOption("-uninstallservice"))
|
|
|
|
|
{
|
|
|
|
|
logger.Info("Performing service uninstallation");
|
|
|
|
|
UninstallService(ApplicationPath, logger);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// Uninstall directly
|
|
|
|
|
if (options.ContainsOption("-uninstallservice"))
|
|
|
|
|
{
|
|
|
|
|
logger.Info("Performing service uninstallation");
|
|
|
|
|
UninstallService(ApplicationPath, logger);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Restart with admin rights, then uninstall
|
|
|
|
|
if (options.ContainsOption("-uninstallserviceasadmin"))
|
|
|
|
|
{
|
|
|
|
|
logger.Info("Performing service uninstallation");
|
|
|
|
|
RunServiceUninstallation(ApplicationPath);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// Restart with admin rights, then uninstall
|
|
|
|
|
if (options.ContainsOption("-uninstallserviceasadmin"))
|
|
|
|
|
{
|
|
|
|
|
logger.Info("Performing service uninstallation");
|
|
|
|
|
RunServiceUninstallation(ApplicationPath);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
|
|
|
|
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
|
|
|
|
|
|
|
|
|
RunServiceInstallationIfNeeded(ApplicationPath);
|
|
|
|
|
RunServiceInstallationIfNeeded(ApplicationPath);
|
|
|
|
|
|
|
|
|
|
if (IsAlreadyRunning(ApplicationPath, currentProcess))
|
|
|
|
|
{
|
|
|
|
|
logger.Info("Shutting down because another instance of Emby Server is already running.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (IsAlreadyRunning(ApplicationPath, currentProcess))
|
|
|
|
|
{
|
|
|
|
|
logger.Info("Shutting down because another instance of Emby Server is already running.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (PerformUpdateIfNeeded(appPaths, logger))
|
|
|
|
|
{
|
|
|
|
|
logger.Info("Exiting to perform application update.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (PerformUpdateIfNeeded(appPaths, logger))
|
|
|
|
|
{
|
|
|
|
|
logger.Info("Exiting to perform application update.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
RunApplication(appPaths, logManager, IsRunningAsService, options);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
OnServiceShutdown();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
RunApplication(appPaths, logManager, IsRunningAsService, options);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
OnServiceShutdown();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|