DJWoodZ / Satisfactory-Discord-Bot

A Discord bot that posts Satisfactory Dedicated Server status information such as online players.
MIT License
17 stars 3 forks source link

Wrong online players after server crash and reboot #28

Closed BartekSz95 closed 6 months ago

BartekSz95 commented 7 months ago

I have little problem with online players on server. When my server crash and restart, the bot shows the last number of players on the server, not the current number (this should be zero on startup). To fix this, I need to restart bot after Satisfactory server crash. It is possible to fix this issue?

DJWoodZ commented 7 months ago

Hi @BartekSz95,

Thank you for raising this. Yes, it should. When the Satisfactory Dedicated Server crashes, it should create a new log file. This bot should detect that and reset the player count. Here is the code that should do that: https://github.com/DJWoodZ/Satisfactory-Discord-Bot/blob/main/bin/server.js#L211

Assuming you are referring to the activity status within Discord which says 'Playing online: 2/4' or similar, that can take a few moments to update sometimes.

Assuming you have tried waiting a minute or two before restarting this bot, the next thing to check would be whether the Satisfactory Dedicated Server log is actually being re-created correctly when it crashes. You can confirm this by looking at the files in the Satisfactory Dedicated Server's log directory and the timestamps shown within the files. If the Satisfactory Dedicated Server does not appear to be rotating the log file properly, it's most likely due to a file permission issue that is preventing it from doing so.

Once you have confirmed that the Satisfactory Dedicated Server is creating a new log file with the same filename following a crash, the next thing you could try would be setting this option to true, which will force it to use a method for monitoring the file which can sometimes be more reliable.

SATISFACTORY_BOT_LOG_USE_WATCH_FILE=true

If none of the above helps, please can you provide details to help me to further understand and possibly re-create the issue.

Firstly, can you provide details from the Discord bot's log file around the time a crash occurs (several minutes before and after).

Secondly, can you provide some details of your setup and how you are running both the Satisfactory Dedicated Server and this bot. For example, which branch of the game are you running (stable vs experimental), is the bot accessing the log file in an unusual way (e.g. via a mounted remote file system or similar), etc.

Thanks.