public static void BeginUpdate() { try { UserServiceSpawner.Stop(); //Create updating.info which will warn any sub-processes currently initializing that they should halt File.WriteAllText(Path.Combine(Settings.Location, "updating.info"), "foobar"); //Give time for any sub-processes that may be in the middle of initializing and missed the updating.info file so they can recieve the update pipe notice Thread.Sleep(1000); //Notify all FOG sub processes that an update is about to occur dynamic json = new JObject(); json.action = "start"; Bus.Emit(Bus.Channel.Update, json, true); //Kill any FOG sub processes still running after the notification KillSubProcesses(); //Launch the updater Log.Entry(LogName, "Spawning update helper"); ProcessHandler.RunClientEXE(Path.Combine("tmp", "FOGUpdateHelper.exe"), $"\"{Log.FilePath}\"", false); } catch (Exception ex) { Log.Error(LogName, "Unable to perform update"); Log.Error(LogName, ex); } }
protected override void Load() { Bus.SetMode(Bus.Mode.Server); dynamic json = new JObject(); json.action = "load"; Bus.Emit(Bus.Channel.Status, json, true); if (Settings.OS == Settings.OSType.Linux) { UserServiceSpawner.Start(); } }
protected override void Unload() { UserServiceSpawner.Stop(); dynamic json = new JObject(); json.action = "unload"; Bus.Emit(Bus.Channel.Status, json, true); Bus.Dispose(); // Kill the sub-processes UserServiceSpawner.KillAll(); ProcessHandler.KillAllEXE("FOGUserService"); ProcessHandler.KillAllEXE("FOGTray"); }
private static void KillSubProcesses() { try { UserServiceSpawner.KillAll(); Thread.Sleep(5 * 1000); ProcessHandler.KillAllEXE("FOGUserService"); ProcessHandler.KillAllEXE("FOGTray"); Thread.Sleep(5 * 1000); } catch (Exception ex) { Log.Error(LogName, "Could not stop sub processes"); Log.Error(LogName, ex); } }