mirror of
https://github.com/JustArchiNET/ArchiSteamFarm
synced 2024-11-10 07:04:27 +00:00
Make --process-required default, add ShutdownIfPossible instead
This commit is contained in:
parent
656c1b8d5d
commit
10986289e6
7 changed files with 18 additions and 11 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"]
|
||||
|
|
|
@ -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"]
|
||||
|
|
Loading…
Reference in a new issue