public static void Main(string[] args) { var applicationPath = Assembly.GetEntryAssembly().Location; var options = new StartupOptions(); // Allow this to be specified on the command line. var customProgramDataPath = options.GetOption("-programdata"); var appPaths = CreateApplicationPaths(applicationPath, customProgramDataPath); var logManager = new NlogManager(appPaths.LogDirectoryPath, "server"); logManager.ReloadLogger(LogSeverity.Info); logManager.AddConsoleOutput(); var logger = _logger = logManager.GetLogger("Main"); ApplicationHost.LogEnvironmentInfo(logger, appPaths, true); AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; try { RunApplication(appPaths, logManager, options); } finally { logger.Info("Shutting down"); _appHost.Dispose(); } }
static void Main(string[] args) { SQLitePCL.raw.SetProvider(new SQLitePCL.SQLite3Provider_sqlite3()); var applicationPath = Assembly.GetEntryAssembly().Location; var options = new StartupOptions(Environment.GetCommandLineArgs()); // Allow this to be specified on the command line. var customProgramDataPath = options.GetOption("-programdata"); var appFolderPath = Path.GetDirectoryName(applicationPath); var appPaths = CreateApplicationPaths(appFolderPath, customProgramDataPath); var logManager = new NlogManager(appPaths.LogDirectoryPath, "server"); logManager.ReloadLogger(LogSeverity.Info); logManager.AddConsoleOutput(); var logger = _logger = logManager.GetLogger("Main"); ApplicationHost.LogEnvironmentInfo(logger, appPaths, true); AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; StartApplication(appPaths, logManager, options); NSApplication.Init(); NSApplication.Main(args); }
public static void Main(string[] args) { Application.Init(); var appPaths = CreateApplicationPaths(); var logManager = new NlogManager(appPaths.LogDirectoryPath, "server"); logManager.ReloadLogger(LogSeverity.Info); var logger = _logger = logManager.GetLogger("Main"); BeginLog(logger); AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; if (PerformUpdateIfNeeded(appPaths, logger)) { logger.Info("Exiting to perform application update."); return; } try { RunApplication(appPaths, logManager); } finally { logger.Info("Shutting down"); _appHost.Dispose(); } }
/// <summary> /// Initializes a new instance of the <see cref="BaseApplicationHost{TApplicationPathsType}"/> class. /// </summary> protected BaseApplicationHost() { FailedAssemblies = new List <string>(); LogManager = new NlogManager(ApplicationPaths.LogDirectoryPath, LogFilePrefixName); ConfigurationManager = GetConfigurationManager(); }
/// <summary> /// Defines the entry point of the application. /// </summary> public static void Main(string[] args) { var options = new StartupOptions(Environment.GetCommandLineArgs()); var environmentInfo = new EnvironmentInfo(); var baseDirectory = System.AppContext.BaseDirectory; string archPath = baseDirectory; if (environmentInfo.SystemArchitecture == MediaBrowser.Model.System.Architecture.X64) { archPath = Path.Combine(archPath, "x64"); } else if (environmentInfo.SystemArchitecture == MediaBrowser.Model.System.Architecture.X86) { archPath = Path.Combine(archPath, "x86"); } else { archPath = Path.Combine(archPath, "arm"); } //Wand.SetMagickCoderModulePath(architecturePath); if (environmentInfo.OperatingSystem == MediaBrowser.Model.System.OperatingSystem.Windows) { SetDllDirectory(archPath); } var appPaths = CreateApplicationPaths(baseDirectory); SetSqliteProvider(); var logManager = new NlogManager(appPaths.LogDirectoryPath, "server"); logManager.ReloadLogger(LogSeverity.Debug); logManager.AddConsoleOutput(); var logger = _logger = logManager.GetLogger("Main"); ApplicationHost.LogEnvironmentInfo(logger, appPaths, true); AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; //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; } RunApplication(appPaths, logManager, options, environmentInfo); }
public static void Main() { bool createdNew; _singleInstanceMutex = new Mutex(true, @"Local\" + typeof(App).Assembly.GetName().Name, out createdNew); if (!createdNew) { _singleInstanceMutex = null; return; } var appPath = Process.GetCurrentProcess().MainModule.FileName; // Look for the existence of an update archive var appPaths = new ApplicationPaths(GetProgramDataPath(appPath), appPath); var logManager = new NlogManager(appPaths.LogDirectoryPath, "theater"); logManager.ReloadLogger(LogSeverity.Debug); var updateArchive = Path.Combine(appPaths.TempUpdatePath, "MBTheater" + ".zip"); if (File.Exists(updateArchive)) { // Update is there - execute update try { new ApplicationUpdater().UpdateApplication(appPaths, updateArchive, logManager.GetLogger("ApplicationUpdater"), string.Empty); // And just let the app exit so it can update return; } catch (Exception e) { MessageBox.Show(string.Format("Error attempting to update application.\n\n{0}\n\n{1}", e.GetType().Name, e.Message)); } } var application = new App(appPaths, logManager); application.Run(); }
public static void Main(string[] args) { //GetEntryAssembly is empty when running from a mkbundle package #if MONOMKBUNDLE var applicationPath = GetExecutablePath(); #else var applicationPath = Assembly.GetEntryAssembly().Location; #endif var options = new StartupOptions(); // Allow this to be specified on the command line. var customProgramDataPath = options.GetOption("-programdata"); var appPaths = CreateApplicationPaths(applicationPath, customProgramDataPath); var logManager = new NlogManager(appPaths.LogDirectoryPath, "server"); logManager.ReloadLogger(LogSeverity.Info); logManager.AddConsoleOutput(); var logger = _logger = logManager.GetLogger("Main"); BeginLog(logger, appPaths); AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; if (PerformUpdateIfNeeded(appPaths, logger)) { logger.Info("Exiting to perform application update."); return; } try { RunApplication(appPaths, logManager, options); } finally { logger.Info("Shutting down"); _appHost.Dispose(); } }
public static void Main() { var options = new StartupOptions(Environment.GetCommandLineArgs()); IsRunningAsService = options.ContainsOption("-service"); if (IsRunningAsService) { //_canRestartService = CanRestartWindowsService(); } var currentProcess = Process.GetCurrentProcess(); ApplicationPath = currentProcess.MainModule.FileName; var architecturePath = Path.Combine(Path.GetDirectoryName(ApplicationPath), Environment.Is64BitProcess ? "x64" : "x86"); var success = SetDllDirectory(architecturePath); SQLitePCL.raw.SetProvider(new SQLitePCL.SQLite3Provider_sqlite3()); var appPaths = CreateApplicationPaths(ApplicationPath, IsRunningAsService); var logManager = new NlogManager(appPaths.LogDirectoryPath, "server"); logManager.ReloadLogger(LogSeverity.Debug); logManager.AddConsoleOutput(); var logger = _logger = logManager.GetLogger("Main"); ApplicationHost.LogEnvironmentInfo(logger, appPaths, true); // 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; } // 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; } AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; RunServiceInstallationIfNeeded(ApplicationPath); 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; } try { RunApplication(appPaths, logManager, IsRunningAsService, options); } finally { OnServiceShutdown(); } }
/// <summary> /// Defines the entry point of the application. /// </summary> public static void Main() { var startFlag = Environment.GetCommandLineArgs().ElementAtOrDefault(1); _isRunningAsService = string.Equals(startFlag, "-service", StringComparison.OrdinalIgnoreCase); var applicationPath = Process.GetCurrentProcess().MainModule.FileName; var appPaths = CreateApplicationPaths(applicationPath, _isRunningAsService); var logManager = new NlogManager(appPaths.LogDirectoryPath, "server"); logManager.ReloadLogger(LogSeverity.Debug); logManager.AddConsoleOutput(); var logger = _logger = logManager.GetLogger("Main"); BeginLog(logger, appPaths); // Install directly if (string.Equals(startFlag, "-installservice", StringComparison.OrdinalIgnoreCase)) { logger.Info("Performing service installation"); InstallService(applicationPath, logger); return; } // Restart with admin rights, then install if (string.Equals(startFlag, "-installserviceasadmin", StringComparison.OrdinalIgnoreCase)) { logger.Info("Performing service installation"); RunServiceInstallation(applicationPath); return; } // Uninstall directly if (string.Equals(startFlag, "-uninstallservice", StringComparison.OrdinalIgnoreCase)) { logger.Info("Performing service uninstallation"); UninstallService(applicationPath, logger); return; } // Restart with admin rights, then uninstall if (string.Equals(startFlag, "-uninstallserviceasadmin", StringComparison.OrdinalIgnoreCase)) { logger.Info("Performing service uninstallation"); RunServiceUninstallation(applicationPath); return; } AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; RunServiceInstallationIfNeeded(applicationPath); var currentProcess = Process.GetCurrentProcess(); if (IsAlreadyRunning(applicationPath, currentProcess)) { logger.Info("Shutting down because another instance of Media Browser Server is already running."); return; } if (PerformUpdateIfNeeded(appPaths, logger)) { logger.Info("Exiting to perform application update."); return; } try { RunApplication(appPaths, logManager, _isRunningAsService); } finally { OnServiceShutdown(); } }
static void Main() { AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; bool createdNew; _singleInstanceMutex = new Mutex(true, @"Local\" + typeof(Program).Assembly.GetName().Name, out createdNew); if (!createdNew) { _singleInstanceMutex = null; return; } var appPath = Process.GetCurrentProcess().MainModule.FileName; // Look for the existence of an update archive var appPaths = new ApplicationPaths(GetProgramDataPath(appPath), appPath); var logManager = new NlogManager(appPaths.LogDirectoryPath, "theater"); logManager.ReloadLogger(LogSeverity.Debug); var updateArchive = Path.Combine(appPaths.TempUpdatePath, UpdatePackageName); if (File.Exists(updateArchive)) { ReleaseMutex(); // Update is there - execute update try { new ApplicationUpdater().UpdateApplication(appPaths, updateArchive, logManager.GetLogger("ApplicationUpdater")); // And just let the app exit so it can update return; } catch (Exception e) { MessageBox.Show(string.Format("Error attempting to update application.\n\n{0}\n\n{1}", e.GetType().Name, e.Message)); } } _logger = logManager.GetLogger("App"); try { var task = InstallVcredistIfNeeded(_appHost, _logger); Task.WaitAll(task); _appHost = new ApplicationHost(appPaths, logManager); var initTask = _appHost.Init(new Progress <Double>()); Task.WaitAll(initTask); var electronTask = StartElectron(appPaths); Task.WaitAll(electronTask); var electronProcess = electronTask.Result; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); _mainForm = new MainForm(_logger, _appHost.TheaterConfigurationManager, _appHost, electronProcess); Application.Run(_mainForm); } catch (Exception ex) { _logger.ErrorException("Error launching application", ex); MessageBox.Show("There was an error launching Emby: " + ex.Message); // Shutdown the app with an error code Environment.Exit(1); } finally { ReleaseMutex(); } }
/// <summary> /// Defines the entry point of the application. /// </summary> public static void Main() { var options = new StartupOptions(); _isRunningAsService = options.ContainsOption("-service"); var currentProcess = Process.GetCurrentProcess(); var applicationPath = currentProcess.MainModule.FileName; //Wand.SetMagickCoderModulePath(Path.Combine(Path.GetDirectoryName(applicationPath), "ImageMagickCoders", "x86")); var appPaths = CreateApplicationPaths(applicationPath, _isRunningAsService); var logManager = new NlogManager(appPaths.LogDirectoryPath, "server"); logManager.ReloadLogger(LogSeverity.Debug); logManager.AddConsoleOutput(); var logger = _logger = logManager.GetLogger("Main"); ApplicationHost.LogEnvironmentInfo(logger, appPaths, true); // 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; } // 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; } AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; RunServiceInstallationIfNeeded(applicationPath); if (IsAlreadyRunning(applicationPath, currentProcess)) { logger.Info("Shutting down because another instance of Media Browser Server is already running."); return; } if (PerformUpdateIfNeeded(appPaths, logger)) { logger.Info("Exiting to perform application update."); return; } try { RunApplication(appPaths, logManager, _isRunningAsService, options); } finally { OnServiceShutdown(); } }