samolego / SimpleAuth

Simple authentication mod for Fabric or Forge servers.
https://modrinth.com/mod/SimpleAuth
MIT License
39 stars 14 forks source link

[BUG] [Fabric] Server isn't marked as off even after clearly there isn't anything running #16

Closed IotaBread closed 4 years ago

IotaBread commented 4 years ago

Mod Loader

Versions

Describe the bug When I either try stopping or restarting my server, with a pterodactyl panel, I get this on the console

[Raw Power Daemon] Server marked as STOPPING
[Server thread/INFO]: Stopping the server
[Server thread/INFO]: Stopping server
[Server thread/INFO]: Saving players
[Server thread/INFO]: Saving worlds
[Server thread/INFO]: Saving chunks for level 'ServerLevel[level]'/minecraft:overworld
[Server thread/INFO]: ThreadedAnvilChunkStorage (level): All chunks are saved
[Server thread/INFO]: Saving chunks for level 'ServerLevel[level]'/minecraft:the_nether
[Server thread/INFO]: ThreadedAnvilChunkStorage (DIM-1): All chunks are saved
[Server thread/INFO]: Saving chunks for level 'ServerLevel[level]'/minecraft:the_end
[Server thread/INFO]: ThreadedAnvilChunkStorage (DIM1): All chunks are saved
[Server thread/INFO]: ThreadedAnvilChunkStorage (level): All chunks are saved
[Server thread/INFO]: ThreadedAnvilChunkStorage (DIM-1): All chunks are saved
[Server thread/INFO]: ThreadedAnvilChunkStorage (DIM1): All chunks are saved
[Server thread/INFO]: [SimpleAuth] Shutting down SimpleAuth.
[Server thread/INFO]: [SimpleAuth] Database connection closed successfully.

What should happen now is that this ([Raw Power Daemon] Server marked as OFF) gets sent on the console, but, even after waiting for an hour, nothing happens. Every time, I have to kill the server and this gets sent on the console (this is from a restart. On a stop, only the last two lines get sent.), probably meaning that it already was off, but the panel didn't notice it.

[Raw Power Daemon] Server marked as OFF
[Raw Power Daemon] Server marked as STARTING
[Raw Power Daemon] Checking size of server data directory...
[Raw Power Daemon] Disk Usage: 22786M / 50000M
[Raw Power Daemon] Ensuring correct ownership of files.
[Raw Power Daemon] Running server preflight.
[Raw Power Daemon] Starting server container.
[Raw Power Daemon] Server marked as ON
[Raw Power Daemon] Server marked as OFF
[Raw Power Daemon] Server marked as KILLED.

I've been having this issue for a month, but I couldn't check what was causing it. A while ago I had the opportunity to try finding what was causing the issue and the first thing I tried was removing the mod file, and it worked as expected and not as it's currently doing

To Reproduce Steps to reproduce the behaviour:

  1. Using the pterodactyl panel, start a server with the mod on it
  2. Try using either the stop or the restart
  3. See that in the console no message is sent after the [Server thread/INFO]: [SimpleAuth] Database connection closed successfully., but also the server isn't restarting or off. Instead, it still is on Stopping state

Expected behaviour This should get logged on the console and the server should restart

[Raw Power Daemon] Server marked as STOPPING
[Server thread/INFO]: Stopping the server
[Server thread/INFO]: Stopping server
[Server thread/INFO]: Saving players
[Server thread/INFO]: Saving worlds
[Server thread/INFO]: Saving chunks for level 'ServerLevel[level]'/minecraft:overworld
[Server thread/INFO]: ThreadedAnvilChunkStorage (level): All chunks are saved
[Server thread/INFO]: Saving chunks for level 'ServerLevel[level]'/minecraft:the_nether
[Server thread/INFO]: ThreadedAnvilChunkStorage (DIM-1): All chunks are saved
[Server thread/INFO]: Saving chunks for level 'ServerLevel[level]'/minecraft:the_end
[Server thread/INFO]: ThreadedAnvilChunkStorage (DIM1): All chunks are saved
[Server thread/INFO]: ThreadedAnvilChunkStorage (level): All chunks are saved
[Server thread/INFO]: ThreadedAnvilChunkStorage (DIM-1): All chunks are saved
[Server thread/INFO]: ThreadedAnvilChunkStorage (DIM1): All chunks are saved
[Server thread/INFO]: [SimpleAuth] Shutting down SimpleAuth.
[Server thread/INFO]: [SimpleAuth] Database connection closed successfully.
[Raw Power Daemon] Server marked as OFF

Additional context I'm currently using dedicatedmc.io as the host of my server and had the same issue on another host, but with the same panel (Pterodactyl)

IotaBread commented 4 years ago

Btw, here is the console when I tried restarting without the mod

[05:05:41] [Server thread/INFO]: Stopping the server
[05:05:41] [Server thread/INFO]: Stopping server
[05:05:41] [Server thread/INFO]: Saving players
[05:05:41] [Server thread/INFO]: Saving worlds
[05:05:41] [Server thread/INFO]: Saving chunks for level 'ServerLevel[level]'/minecraft:overworld
[05:05:43] [Server thread/INFO]: ThreadedAnvilChunkStorage (level): All chunks are saved
[05:05:43] [Server thread/INFO]: Saving chunks for level 'ServerLevel[level]'/minecraft:the_nether
[05:05:43] [Server thread/INFO]: ThreadedAnvilChunkStorage (DIM-1): All chunks are saved
[05:05:43] [Server thread/INFO]: Saving chunks for level 'ServerLevel[level]'/minecraft:the_end
[05:05:43] [Server thread/INFO]: ThreadedAnvilChunkStorage (DIM1): All chunks are saved
[05:05:43] [Server thread/INFO]: ThreadedAnvilChunkStorage (level): All chunks are saved
[05:05:43] [Server thread/INFO]: ThreadedAnvilChunkStorage (DIM-1): All chunks are saved
[05:05:43] [Server thread/INFO]: ThreadedAnvilChunkStorage (DIM1): All chunks are saved
[Raw Power Daemon] Server marked as OFF
[Raw Power Daemon] Server marked as STARTING
[Raw Power Daemon] Checking size of server data directory...
[Raw Power Daemon] Disk Usage: 22786M / 50000M
[Raw Power Daemon] Ensuring correct ownership of files.
[Raw Power Daemon] Running server preflight.
[Raw Power Daemon] Starting server container.
...
samolego commented 4 years ago

First off, thanks for such a great report :smile:. I'm able to reproduce this with screen in "normal" linux as well.

It seems kinda weird. I will play around with other entrypoints for server stopping and see if it's any better.

samolego commented 4 years ago

Fabric API provides 2 events executed at stopping the server; SERVER_STOPPING and SERVER_STOPPED. SimpleAuth is using the later, otherwise NPE is thrown since players are just about to be disconnected when mod starts de-authenticating them. I'll look around for a bit more or in the worst-case-scenario create my own event for stopping.

IotaBread commented 4 years ago

Ok, thank you! Hope this gets solved

samolego commented 4 years ago

This should be fixed in SimpleAuth 1.5.2 by commit f480e93ed2c56c169c66826fc576db2d0d574039. ExecutorService thread wasn't closed ... If you are still experiencing this issue, feel free to reopen.

IotaBread commented 4 years ago

Thank you!