diff --git a/ArchiSteamFarm/Core/Events.cs b/ArchiSteamFarm/Core/Events.cs index abc4f143d..ba66ceb93 100644 --- a/ArchiSteamFarm/Core/Events.cs +++ b/ArchiSteamFarm/Core/Events.cs @@ -25,12 +25,15 @@ using System.Linq; using System.Threading.Tasks; using ArchiSteamFarm.Localization; using ArchiSteamFarm.Steam; +using ArchiSteamFarm.Storage; namespace ArchiSteamFarm.Core; internal static class Events { internal static async Task OnBotShutdown() { - if (Program.ProcessRequired || ((Bot.Bots != null) && Bot.Bots.Values.Any(static bot => bot.KeepRunning))) { + bool shutdownIfPossible = ASF.GlobalConfig?.ShutdownIfPossible ?? GlobalConfig.DefaultShutdownIfPossible; + + if (!shutdownIfPossible || (Bot.Bots?.Values.Any(static bot => bot.KeepRunning) == true)) { return; } @@ -39,7 +42,7 @@ internal static class Events { // We give user extra 5 seconds for eventual config changes await Task.Delay(5000).ConfigureAwait(false); - if (Program.ProcessRequired || ((Bot.Bots != null) && Bot.Bots.Values.Any(static bot => bot.KeepRunning))) { + if (Bot.Bots?.Values.Any(static bot => bot.KeepRunning) == true) { return; } diff --git a/ArchiSteamFarm/Program.cs b/ArchiSteamFarm/Program.cs index bc372bf70..d7661d447 100644 --- a/ArchiSteamFarm/Program.cs +++ b/ArchiSteamFarm/Program.cs @@ -54,7 +54,6 @@ internal static class Program { internal static bool ConfigWatch { get; private set; } = true; internal static bool IgnoreUnsupportedEnvironment { get; private set; } internal static string? NetworkGroup { get; private set; } - internal static bool ProcessRequired { get; private set; } internal static bool RestartAllowed { get; private set; } = true; internal static bool Service { get; private set; } internal static bool ShutdownSequenceInitialized { get; private set; } @@ -593,10 +592,6 @@ internal static class Program { case "--NO-STEAM-PARENTAL-GENERATION" when noArgumentValueNext(): SteamParentalGeneration = false; - break; - case "--PROCESS-REQUIRED" when noArgumentValueNext(): - ProcessRequired = true; - break; case "--PATH" when noArgumentValueNext(): pathNext = true; diff --git a/ArchiSteamFarm/Storage/GlobalConfig.cs b/ArchiSteamFarm/Storage/GlobalConfig.cs index 82c6cd737..d73750856 100644 --- a/ArchiSteamFarm/Storage/GlobalConfig.cs +++ b/ArchiSteamFarm/Storage/GlobalConfig.cs @@ -112,6 +112,9 @@ public sealed class GlobalConfig { [PublicAPI] public const EPluginsUpdateMode DefaultPluginsUpdateMode = EPluginsUpdateMode.Whitelist; + [PublicAPI] + public const bool DefaultShutdownIfPossible = true; + [PublicAPI] public const string? DefaultSteamMessagePrefix = "/me "; @@ -293,6 +296,9 @@ public sealed class GlobalConfig { [JsonInclude] public EPluginsUpdateMode PluginsUpdateMode { get; private init; } = DefaultPluginsUpdateMode; + [JsonInclude] + public bool ShutdownIfPossible { get; private init; } = DefaultShutdownIfPossible; + [JsonInclude] [MaxLength(SteamChatMessage.MaxMessagePrefixBytes / SteamChatMessage.ReservedEscapeMessageBytes)] [UnconditionalSuppressMessage("AssemblyLoadTrimming", "IL2026:RequiresUnreferencedCode", Justification = "This is optional, supportive attribute, we don't care if it gets trimmed or not")] @@ -439,6 +445,9 @@ public sealed class GlobalConfig { [UsedImplicitly] public bool ShouldSerializePluginsUpdateMode() => !Saving || (PluginsUpdateMode != DefaultPluginsUpdateMode); + [UsedImplicitly] + public bool ShouldSerializeShutdownIfPossible() => !Saving || (ShutdownIfPossible != DefaultShutdownIfPossible); + [UsedImplicitly] public bool ShouldSerializeSSteamOwnerID() => !Saving; diff --git a/ArchiSteamFarm/overlay/variant-base/linux/ArchiSteamFarm@.service b/ArchiSteamFarm/overlay/variant-base/linux/ArchiSteamFarm@.service index bd3f5f890..cfa801b07 100644 --- a/ArchiSteamFarm/overlay/variant-base/linux/ArchiSteamFarm@.service +++ b/ArchiSteamFarm/overlay/variant-base/linux/ArchiSteamFarm@.service @@ -3,7 +3,7 @@ WantedBy=multi-user.target [Service] EnvironmentFile=-/etc/asf/%i -ExecStart=/home/%i/ArchiSteamFarm/ArchiSteamFarm --no-restart --process-required --service --system-required +ExecStart=/home/%i/ArchiSteamFarm/ArchiSteamFarm --no-restart --service --system-required Restart=on-success RestartSec=1s SyslogIdentifier=asf-%i diff --git a/ArchiSteamFarm/overlay/variant-specific/generic/ArchiSteamFarm@.service b/ArchiSteamFarm/overlay/variant-specific/generic/ArchiSteamFarm@.service index 6669ddb86..97fb31580 100644 --- a/ArchiSteamFarm/overlay/variant-specific/generic/ArchiSteamFarm@.service +++ b/ArchiSteamFarm/overlay/variant-specific/generic/ArchiSteamFarm@.service @@ -3,7 +3,7 @@ WantedBy=multi-user.target [Service] EnvironmentFile=-/etc/asf/%i -ExecStart=dotnet /home/%i/ArchiSteamFarm/ArchiSteamFarm.dll --no-restart --process-required --service --system-required +ExecStart=dotnet /home/%i/ArchiSteamFarm/ArchiSteamFarm.dll --no-restart --service --system-required Restart=on-success RestartSec=1s SyslogIdentifier=asf-%i diff --git a/Dockerfile b/Dockerfile index 801237812..148e580c1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -84,4 +84,4 @@ RUN set -eu; \ VOLUME ["/app/config", "/app/logs"] HEALTHCHECK CMD ["pidof", "-q", "dotnet"] -ENTRYPOINT ["ArchiSteamFarm", "--no-restart", "--process-required", "--system-required"] +ENTRYPOINT ["ArchiSteamFarm", "--no-restart", "--system-required"] diff --git a/Dockerfile.Service b/Dockerfile.Service index e14a4e810..b2b2d5632 100644 --- a/Dockerfile.Service +++ b/Dockerfile.Service @@ -84,4 +84,4 @@ RUN set -eu; \ VOLUME ["/app/config", "/app/logs"] HEALTHCHECK CMD ["pidof", "-q", "ArchiSteamFarm"] -ENTRYPOINT ["ArchiSteamFarm", "--no-restart", "--process-required", "--system-required"] +ENTRYPOINT ["ArchiSteamFarm", "--no-restart", "--system-required"]