JustArchiNET / ArchiSteamFarm

C# application with primary purpose of farming Steam cards from multiple accounts simultaneously.
Apache License 2.0
11.09k stars 1.04k forks source link

Sometimes after closing the terminal ASF continues running in the background and consuming 100% of a core #3050

Closed andreldmonteiro closed 11 months ago

andreldmonteiro commented 11 months ago

Checklist

ASF version

Latest stable release

ASF variant

linux-x64

Bug description

Sometimes after closing the terminal that is running ASF, the process continues running in the background and consuming 100% of a core.

Expected behavior

The process should had been terminated.

Actual behavior

ASF continues running in the background and consuming 100% of a core.

Steps to reproduce

No response

Possible reason/solution

Perhaps happens when there is a new update and it is installed.

Can you help us with this bug report?

Somehow, I can test and offer feedback, but can't code

Full log.txt recorded during reproducing the problem

2023-10-21 15:31:03|ArchiSteamFarm-11892|INFO|ASF|InitCore() ArchiSteamFarm V5.4.12.5 (linux-x64/a6f1d4c3-7e5e-41d8-b57a-d8593494717f | .NET 7.0.12; fedora.39-x64; Linux 6.5.6-300.fc39.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Oct  6 19:57:21 UTC 2023)
2023-10-21 15:31:03|ArchiSteamFarm-11892|INFO|ASF|InitCore() Copyright © 2015-2023 JustArchiNET
2023-10-21 15:31:03|ArchiSteamFarm-11892|INFO|ASF|InitPlugins() A inicializar Plugins...
2023-10-21 15:31:03|ArchiSteamFarm-11892|INFO|ASF|InitPlugins() Carregando SteamTokenDumperPlugin V5.4.12.5...
2023-10-21 15:31:03|ArchiSteamFarm-11892|INFO|ASF|WarnAboutIncompleteTranslation() O ASF tentará usar o seu idioma preferido pt-PT (Portuguese (Portugal)), mas a tradução para essa língua está apenas 31,0% completa. Talvez nos queira ajudar a melhorar a tradução do ASF para a sua língua?
2023-10-21 15:31:03|ArchiSteamFarm-11892|INFO|ASF|InitPlugins() SteamTokenDumperPlugin foi carregado com sucesso!
2023-10-21 15:31:03|ArchiSteamFarm-11892|INFO|ASF|InitPlugins() Carregando ItemsMatcherPlugin V5.4.12.5...
2023-10-21 15:31:03|ArchiSteamFarm-11892|INFO|ASF|InitPlugins() ItemsMatcherPlugin foi carregado com sucesso!
2023-10-21 15:31:03|ArchiSteamFarm-11892|INFO|ASF|InitPlugins() Carregando MobileAuthenticatorPlugin V5.4.12.5...
2023-10-21 15:31:03|ArchiSteamFarm-11892|INFO|ASF|InitPlugins() MobileAuthenticatorPlugin foi carregado com sucesso!
2023-10-21 15:31:03|ArchiSteamFarm-11892|INFO|ASF|UpdateAndRestart() O ASF vai automaticamente procurar por novas versões a cada 1 dia.
2023-10-21 15:31:03|ArchiSteamFarm-11892|INFO|ASF|Update() A limpar ficheiros antigos após a atualização...
2023-10-21 15:31:04|ArchiSteamFarm-11892|INFO|ASF|Update() Feito!
2023-10-21 15:31:04|ArchiSteamFarm-11892|INFO|ASF|Update() A procurar por novas versões...
2023-10-21 15:31:04|ArchiSteamFarm-11892|INFO|ASF|Update() Versão local: 5.4.12.5 | Versão remota: 5.4.12.5
2023-10-21 15:31:04|ArchiSteamFarm-11892|INFO|ASF|OnASFInit() SteamTokenDumperPlugin está atualmente desativado de acordo com a sua configuração. Se quiser ajudar o SteamDB na submissão de dados, por favor confira o nosso wiki.
2023-10-21 15:31:04|ArchiSteamFarm-11892|INFO|ASF|StartInteractiveConsole() A consola interativa está agora ativa, digite 'c' para entrar no modo de comando.
2023-10-21 15:31:04|ArchiSteamFarm-11892|INFO|ASF|Start() A inicializar o servidor IPC...
2023-10-21 15:31:05|ArchiSteamFarm-11892|INFO|Microsoft.Hosting.Lifetime|Now listening on: http://localhost:1242
2023-10-21 15:31:05|ArchiSteamFarm-11892|INFO|Microsoft.Hosting.Lifetime|Application started. Press Ctrl+C to shut down.
2023-10-21 15:31:05|ArchiSteamFarm-11892|INFO|Microsoft.Hosting.Lifetime|Hosting environment: Production
2023-10-21 15:31:05|ArchiSteamFarm-11892|INFO|Microsoft.Hosting.Lifetime|Content root path: /var/home/*****/*******/*****
2023-10-21 15:31:05|ArchiSteamFarm-11892|INFO|ASF|Start() Servidor IPC pronto!
2023-10-21 15:31:05|ArchiSteamFarm-11892|INFO|bot|Start() A iniciar...
2023-10-21 15:31:05|ArchiSteamFarm-11892|INFO|bot|Connect() A ligar...
2023-10-21 15:31:05|ArchiSteamFarm-11892|INFO|bot|OnConnected() Conectado ao Steam!
2023-10-21 15:31:05|ArchiSteamFarm-11892|INFO|bot|OnConnected() A iniciar sessão...
2023-10-21 15:31:06|ArchiSteamFarm-11892|INFO|bot|OnLoggedOn() Login com sucesso como ****************/****************.
2023-10-21 15:31:06|ArchiSteamFarm-11892|INFO|bot|Init() Sucesso!
2023-10-21 15:31:09|ArchiSteamFarm-11892|INFO|bot|IsAnythingToFarm() A verificar a primeira página de medalhas...
2023-10-21 15:31:10|ArchiSteamFarm-11892|INFO|bot|IsAnythingToFarm() A verificar as outras páginas de medalhas...
2023-10-21 15:31:22|ArchiSteamFarm-11892|INFO|bot|StartFarming() Não temos nada para 'farmar' nesta conta!

Global ASF.json config file

No response

BotName.json config of all affected bot instances

{
  "Enabled": true,
  "OnlineStatus": 0,
  "RemoteCommunication": 0,
  "SteamLogin": "*******",
  "SteamPassword": "*******"
}

Additional info

No response

JustArchi commented 11 months ago

ASF can't "continue in the background" if you shutdown/kill the process, ASF doesn't spawn any child processes to do that. I'd rather consult the way you run the program, as I don't believe there is anything to fix/improve in ASF in this regard.

If you can reliably reproduce it by using !exit command, open new support thread and attach full log.txt, then maybe I'll have some ideas where to look for the issue on your machine. If not, then that's entirely OS/machine issue.

andreldmonteiro commented 11 months ago

Normally the terminal asks always if I want to close it when ASF is running saying it will kill the process in doing so, but in this case it doesn't (when it downloaded an update, installed it and resumed farming) when I close it and the process continues in the background consuming 100% of a core and doing nothing because there was no more games to farm.

JustArchi commented 11 months ago

Ah, okay, you're refering to something entirely different - ASF spawns new process after update and kills/stops existing one, in this case indeed, old process as the only one attached to the console, is automatically closed, and your terminal doesn't have any say over new process, since it's not attached.

Either you can use AutoRestart: false (see config section on the wiki for more info) and automatically start ASF process again after it updates, or use systemd unit (see management section on the wiki for more info) which will do the same.

There is no way for me to restart the process in the same terminal for you after update.

andreldmonteiro commented 11 months ago

Ok, thanks, and the 100% core use can't be done anything about it if left unchecked and forgotten?

JustArchi commented 11 months ago

If ASF is using 100% core then it means it's doing something, such as purging old files after update or something else - log should tell you what it's doing, there is no infinite CPU load for no reason.

andreldmonteiro commented 11 months ago

Well the log is really the one posted here and it is doing nothing: "...Não temos nada para 'farmar' nesta conta!" = nothing to farm on this account.

JustArchi commented 11 months ago

Then there is no reason for ASF to use 100% of CPU. You're doing something wrong, can you show screenshot of that CPU usage?

andreldmonteiro commented 11 months ago

Yes, here it is:

screenshot

JustArchi commented 11 months ago

Is it happening only after update, or did you run into this issue also when ASF is up-to-date and not updating?

andreldmonteiro commented 11 months ago

It only happens after an update, and only goes to 100% after the terminal is closed.

JustArchi commented 11 months ago

Could you do the following:

Download older ASF release (e.g. V5.4.12.3), use "Headless": true setting in ASF.json, then make it update to V5.4.12.5 by launching in terminal as usual, wait for it to upgrade and start, then close terminal as usual. Check if process still uses 100% CPU.

This is the only part related to ASF that could (maybe) cause this scenario, all other parts are runtime-related.

andreldmonteiro commented 11 months ago

Yes, it still happens.

JustArchi commented 11 months ago

I've reproduced your issue on my Linux machine, so it seems global. I don't have a solution for now, you can use AutoRestart: false and manually restart ASF process or use systemd service as per management section in ASF wiki. I'll try to find out the root culprit and code a fix if possible, but I'm not sure if this isn't runtime-related issue I have no say in.

In any case, thanks for report.

JustArchi commented 11 months ago

https://github.com/JustArchiNET/ArchiSteamFarm/issues/3051