From 22cc7e8b88c279b7197b7449d6a69f7ba8df98fd Mon Sep 17 00:00:00 2001 From: Madpeter <57852827+Madpeterz@users.noreply.github.com> Date: Tue, 29 Nov 2022 21:25:09 +0000 Subject: [PATCH] update docker file and tweak services --- Dockerfile | 9 +-------- LibreMetaverse/Settings.cs | 2 +- SecondBotEvents/Services/BotClientService.cs | 2 ++ SecondBotEvents/Services/CommandsService.cs | 2 ++ SecondBotEvents/Services/CustomCommandsService.cs | 3 ++- SecondBotEvents/Services/DataStoreService.cs | 2 ++ SecondBotEvents/Services/DialogService.cs | 2 ++ SecondBotEvents/Services/DiscordService.cs | 4 +++- SecondBotEvents/Services/EventsService.cs | 2 ++ SecondBotEvents/Services/HomeboundService.cs | 2 ++ SecondBotEvents/Services/HttpService.cs | 2 ++ SecondBotEvents/Services/InteractionService.cs | 2 ++ SecondBotEvents/Services/RelayService.cs | 2 ++ SecondBotEvents/Services/Services.cs | 10 +++++++--- 14 files changed, 32 insertions(+), 14 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0cc0d6e..4def020 100644 --- a/Dockerfile +++ b/Dockerfile @@ -47,14 +47,7 @@ ENV Basic_BotUserName='' \ Setting_LogCommands='false' \ Agent_Channel='auto' \ Agent_Version='auto' \ - OBJECT_CHAT='false' \ - SQLDB_Enabled='false' \ - SQLDB_Host='127.0.0.1' \ - SQLDB_Port='3306' \ - SQLDB_Username='' \ - SQLDB_Password='' \ - SQLDB_Timeout='3' \ - SQLDB_Database='secondbot' + OBJECT_CHAT='false' EXPOSE 80 ENV ASPNETCORE_URLS http://+:80 diff --git a/LibreMetaverse/Settings.cs b/LibreMetaverse/Settings.cs index b225174..e081410 100644 --- a/LibreMetaverse/Settings.cs +++ b/LibreMetaverse/Settings.cs @@ -342,7 +342,7 @@ namespace OpenMetaverse /// You will get no output on the console. This behavior can be overriden by creating /// a logger configuration file for log4net /// - public static Helpers.LogLevel LOG_LEVEL = Helpers.LogLevel.Debug; + public static Helpers.LogLevel LOG_LEVEL = Helpers.LogLevel.None; /// Attach avatar names to log messages public bool LOG_NAMES = true; diff --git a/SecondBotEvents/Services/BotClientService.cs b/SecondBotEvents/Services/BotClientService.cs index 0bd3eef..f8b4b2d 100644 --- a/SecondBotEvents/Services/BotClientService.cs +++ b/SecondBotEvents/Services/BotClientService.cs @@ -34,6 +34,7 @@ namespace SecondBotEvents.Services public override void Start() { + running = true; Console.WriteLine("Client service [Starting]"); AutoRestartLoginTimer = new Timer(); AutoRestartLoginTimer.Interval = 30 * 1000; @@ -43,6 +44,7 @@ namespace SecondBotEvents.Services } public override void Stop() { + running = false; AutoRestartLoginTimer.Stop(); Console.WriteLine("Client service [Stopping]"); ResetClient(); diff --git a/SecondBotEvents/Services/CommandsService.cs b/SecondBotEvents/Services/CommandsService.cs index 50831bd..a202429 100644 --- a/SecondBotEvents/Services/CommandsService.cs +++ b/SecondBotEvents/Services/CommandsService.cs @@ -68,11 +68,13 @@ namespace SecondBotEvents.Services } public override void Start() { + running = true; master.BotClientNoticeEvent += BotClientRestart; } public override void Stop() { + running = false; acceptNewCommands = false; } diff --git a/SecondBotEvents/Services/CustomCommandsService.cs b/SecondBotEvents/Services/CustomCommandsService.cs index 21a87eb..544ac8e 100644 --- a/SecondBotEvents/Services/CustomCommandsService.cs +++ b/SecondBotEvents/Services/CustomCommandsService.cs @@ -104,12 +104,13 @@ namespace SecondBotEvents.Services public override void Start() { - Stop(); + running = true; master.BotClientNoticeEvent += BotClientRestart; } public override void Stop() { + running = false; master.BotClientNoticeEvent -= BotClientRestart; } } diff --git a/SecondBotEvents/Services/DataStoreService.cs b/SecondBotEvents/Services/DataStoreService.cs index 0b91c54..739123b 100644 --- a/SecondBotEvents/Services/DataStoreService.cs +++ b/SecondBotEvents/Services/DataStoreService.cs @@ -1043,12 +1043,14 @@ namespace SecondBotEvents.Services public override void Start() { Stop(); + running = true; master.BotClientNoticeEvent += BotClientRestart; Console.WriteLine("DataStore Service [Starting]"); } public override void Stop() { + running = false; Reset(); master.BotClientNoticeEvent -= BotClientRestart; if (master.BotClient != null) diff --git a/SecondBotEvents/Services/DialogService.cs b/SecondBotEvents/Services/DialogService.cs index 130193a..d897d31 100644 --- a/SecondBotEvents/Services/DialogService.cs +++ b/SecondBotEvents/Services/DialogService.cs @@ -220,11 +220,13 @@ namespace SecondBotEvents.Services public override void Start() { Stop(); + running = true; master.BotClientNoticeEvent += BotClientRestart; } public override void Stop() { + running = false; master.BotClientNoticeEvent -= BotClientRestart; } } diff --git a/SecondBotEvents/Services/DiscordService.cs b/SecondBotEvents/Services/DiscordService.cs index 71c8c6c..2996c9a 100644 --- a/SecondBotEvents/Services/DiscordService.cs +++ b/SecondBotEvents/Services/DiscordService.cs @@ -404,7 +404,8 @@ namespace SecondBotEvents.Services public override void Start() { - if(myConfig.GetEnabled() == false) + running = true; + if (myConfig.GetEnabled() == false) { Console.WriteLine("Discord service [Disabled]"); return; @@ -431,6 +432,7 @@ namespace SecondBotEvents.Services public override void Stop() { + running = false; Console.WriteLine("Discord service [Stopping]"); master.BotClientNoticeEvent -= BotClientRestart; master.SystemStatusMessagesEvent -= SystemStatusEvent; diff --git a/SecondBotEvents/Services/EventsService.cs b/SecondBotEvents/Services/EventsService.cs index 753635b..39bfcc9 100644 --- a/SecondBotEvents/Services/EventsService.cs +++ b/SecondBotEvents/Services/EventsService.cs @@ -344,6 +344,7 @@ namespace SecondBotEvents.Services return; } Stop(); + running = true; master.BotClientNoticeEvent += BotClientRestart; master.SystemStatusMessagesEvent += BotStatusMessage; } @@ -354,6 +355,7 @@ namespace SecondBotEvents.Services { return; } + running = false; master.BotClientNoticeEvent -= BotClientRestart; master.SystemStatusMessagesEvent -= BotStatusMessage; removeEvents(); diff --git a/SecondBotEvents/Services/HomeboundService.cs b/SecondBotEvents/Services/HomeboundService.cs index 2754091..218695d 100644 --- a/SecondBotEvents/Services/HomeboundService.cs +++ b/SecondBotEvents/Services/HomeboundService.cs @@ -267,12 +267,14 @@ namespace SecondBotEvents.Services return; } Stop(); + running = true; master.BotClientNoticeEvent += BotClientRestart; Console.WriteLine("Homebound Service [Starting]"); } public override void Stop() { + running = false; master.BotClientNoticeEvent -= BotClientRestart; if (master.BotClient != null) { diff --git a/SecondBotEvents/Services/HttpService.cs b/SecondBotEvents/Services/HttpService.cs index 69f2c28..aa9ce6d 100644 --- a/SecondBotEvents/Services/HttpService.cs +++ b/SecondBotEvents/Services/HttpService.cs @@ -84,11 +84,13 @@ namespace SecondBotEvents.Services return; } Stop(); + running = true; master.BotClientNoticeEvent += BotClientRestart; } public override void Stop() { + running = false; if (myConfig.GetEnabled() == false) { return; diff --git a/SecondBotEvents/Services/InteractionService.cs b/SecondBotEvents/Services/InteractionService.cs index b7e290a..437fab1 100644 --- a/SecondBotEvents/Services/InteractionService.cs +++ b/SecondBotEvents/Services/InteractionService.cs @@ -190,12 +190,14 @@ namespace SecondBotEvents.Services return; } Stop(); + running = true; master.BotClientNoticeEvent += BotClientRestart; Console.WriteLine("Interaction Service [Starting]"); } public override void Stop() { + running = false; if (myConfig.GetEnabled() == false) { return; diff --git a/SecondBotEvents/Services/RelayService.cs b/SecondBotEvents/Services/RelayService.cs index 0c72b78..f46a856 100644 --- a/SecondBotEvents/Services/RelayService.cs +++ b/SecondBotEvents/Services/RelayService.cs @@ -130,12 +130,14 @@ namespace SecondBotEvents.Services public override void Start() { Stop(); + running = true; master.BotClientNoticeEvent += BotClientRestart; Console.WriteLine("Relay Service [Starting]"); } public override void Stop() { + running = false; master.BotClientNoticeEvent -= BotClientRestart; if (master.BotClient != null) { diff --git a/SecondBotEvents/Services/Services.cs b/SecondBotEvents/Services/Services.cs index 6884fbf..ee68736 100644 --- a/SecondBotEvents/Services/Services.cs +++ b/SecondBotEvents/Services/Services.cs @@ -8,6 +8,7 @@ namespace SecondBotEvents.Services public abstract class BotServices { public EventsSecondBot master; + protected bool running = false; public BotServices(EventsSecondBot setMaster) { master = setMaster; @@ -32,15 +33,18 @@ namespace SecondBotEvents.Services public virtual void Start() { - + running = true; } public virtual void Stop() { - + running = false; } public void Restart() { - Stop(); + if (running == true) + { + Stop(); + } Start(); } }