/// <summary> /// Handles the Elapsed event of the _checkGameRunningTimer control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="ElapsedEventArgs"/> instance containing the event data.</param> private void _checkGameRunningTimer_Elapsed(object sender, ElapsedEventArgs e) { Process process = Process.GetProcesses().FirstOrDefault(c => c.ProcessName.Contains(_settings.Atlas.ServerProcessName)); if (process is null) { _logger.LogCritical("Server Process not found to be running. Will try to start now."); if (_steamCmdService.StartAtlasServer()) { _logger.LogInformation("The Atlas Server has been started Successfully!"); } } }
/// <summary> /// Timers the elapsed. /// </summary> /// <param name="e">The <see cref="ElapsedEventArgs"/> instance containing the event data.</param> /// <returns>Task.</returns> private async Task _timer_Elapsed(ElapsedEventArgs e) { await Task.Run(async() => { if (_settings.Update.AnnounceTwitch) { _twitchMessageService.SendMessage(_twitchMessages.TwitchServerUptimeMessage.Replace("@hours", _settings.General.RestartServerAfterHours.ToString())); } if (_settings.Update.AnnounceTwitch) { await _discordMessageService.SendMessage(_discordMessages.DiscordServerUptimeMessage.Replace("@hours", _settings.General.RestartServerAfterHours.ToString())); } if (_settings.Update.AnnounceRCon) { await _rconMessageService.SendMessage(_rconMessages.RconServerUptimeMessage.Replace("@hours", _settings.General.RestartServerAfterHours.ToString())); } await Task.Delay(TimeSpan.FromMinutes(5)); await _steamCmdService.KillAtlas(); if (_settings.Update.AnnounceTwitch) { _twitchMessageService.SendMessage(_twitchMessages.TwitchServerRestartingMessage); } if (_settings.Update.AnnounceTwitch) { await _discordMessageService.SendMessage(_discordMessages.DiscordServerRestartingMessage); } _steamCmdService.StartAtlasServer(); }); }