public Main(string updatedVersion) { Hide(); InitializeComponent(); Opacity = 0; Enabled = false; WindowState = FormWindowState.Minimized; FormBorderStyle = FormBorderStyle.FixedToolWindow; var runtimeSettings = new RuntimeSettings() { CustomLogFileName = "TrayLog.txt" }; LogManager.Configuration = LoggingSetup.GetLoggingConfiguration(runtimeSettings); logger = LogManager.GetCurrentClassLogger(); logger.Info("Starting Jackett Tray v" + EnvironmentUtil.JackettVersion); processService = new ProcessService(logger); windowsService = new WindowsServiceConfigService(processService, logger); trayLockService = new TrayLockService(); serializeService = new SerializeService(); configurationService = new ConfigurationService(serializeService, processService, logger, runtimeSettings); serverConfig = configurationService.BuildServerConfig(runtimeSettings); toolStripMenuItemAutoStart.Checked = AutoStart; toolStripMenuItemAutoStart.CheckedChanged += toolStripMenuItemAutoStart_CheckedChanged; toolStripMenuItemWebUI.Click += toolStripMenuItemWebUI_Click; toolStripMenuItemShutdown.Click += toolStripMenuItemShutdown_Click; if (Environment.OSVersion.Platform == PlatformID.Win32NT) { toolStripMenuItemAutoStart.Visible = true; } if (!windowsService.ServiceExists()) { // We are not installed as a service so just start the web server via JackettConsole and run from the tray. logger.Info("Starting server from tray"); StartConsoleApplication(); } updatedVersion = updatedVersion.Equals("yes", StringComparison.OrdinalIgnoreCase) ? EnvironmentUtil.JackettVersion : updatedVersion; if (!string.IsNullOrWhiteSpace(updatedVersion)) { notifyIcon1.BalloonTipTitle = "Jackett"; notifyIcon1.BalloonTipText = $"Jackett has updated to version {updatedVersion}"; notifyIcon1.BalloonTipIcon = ToolTipIcon.Info; notifyIcon1.ShowBalloonTip(10000); logger.Info($"Display balloon tip, updated to {updatedVersion}"); } Task.Factory.StartNew(WaitForEvent); }
public UpdateService(Logger l, WebClient c, ITrayLockService ls, IServiceConfigService ws, IFilePermissionService fps, ServerConfig sc) { logger = l; client = c; lockService = ls; windowsService = ws; serverConfig = sc; filePermissionService = fps; variant = new Variants().GetVariant(); }
public UpdateService(Logger l, WebClient c, IConfigurationService cfg, ITrayLockService ls, IProcessService ps, IServiceConfigService ws, IFilePermissionService fps, ServerConfig sc) { logger = l; client = c; configService = cfg; lockService = ls; processService = ps; windowsService = ws; serverConfig = sc; filePermissionService = fps; }
private void Run(string[] args) { var runtimeSettings = new RuntimeSettings() { CustomLogFileName = "updater.txt" }; LogManager.Configuration = LoggingSetup.GetLoggingConfiguration(runtimeSettings); logger = LogManager.GetCurrentClassLogger(); logger.Info("Jackett Updater v" + GetCurrentVersion()); logger.Info("Options \"" + string.Join("\" \"", args) + "\""); var variants = new Variants(); variant = variants.GetVariant(); logger.Info("Jackett variant: " + variant.ToString()); var isWindows = Environment.OSVersion.Platform == PlatformID.Win32NT; if (isWindows) { //The updater starts before Jackett closes logger.Info("Pausing for 3 seconds to give Jackett & tray time to shutdown"); System.Threading.Thread.Sleep(3000); } processService = new ProcessService(logger); windowsService = new WindowsServiceConfigService(processService, logger); var commandLineParser = new Parser(settings => settings.CaseSensitive = false); try { var optionsResult = commandLineParser.ParseArguments <UpdaterConsoleOptions>(args); optionsResult.WithParsed(options => { ProcessUpdate(options); } ); optionsResult.WithNotParsed(errors => { logger.Error(HelpText.AutoBuild(optionsResult)); logger.Error("Failed to process update arguments!"); logger.Error(errors.ToString()); Console.ReadKey(); }); } catch (Exception e) { logger.Error(e, "Exception applying update!"); } }
public UpdateService(Logger l, WebClient c, ITrayLockService ls, IServiceConfigService ws, IFilePermissionService fps, ServerConfig sc) { logger = l; client = c; lockService = ls; windowsService = ws; serverConfig = sc; filePermissionService = fps; variant = new Variants().GetVariant(); // Increase the HTTP client timeout just for update download (not other requests) // The update is heavy and can take longer time for slow connections. Fix #12711 client.SetTimeout(300); // 5 minutes }