Commit Graph
16 Commits
Author SHA1 Message Date
evilight 97eff6517e login: probe the world port with a bind test instead of lsof
LoginServer.exec() -> checkServerHealth() -> isPortInUse() shelled out to
`lsof -i tcp:<port>` through /bin/bash and read the child's stdout until EOF.
There is no timeout and no waitFor(), so a child that blocks is fatal: in the
container lsof was observed stuck in uninterruptible I/O (D state) while it was
scanning the busy world server. The login server then never returned from its
startup path, the accept loop never started, and clients could open a TCP
connection to 6000 and wait forever for the 100 byte DH handshake, surfacing as
"Failed to open a server connection" after the client's own timeout. A container
restart was the only way out.

Replace the external probe with a bind probe: it cannot hang, needs no external
tool, and SO_REUSEADDR still does not allow stealing a port that is actively
listening, so a successful bind keeps meaning "free".
2026-10-10 16:06:55 +08:00
evilight 9f3ec7c553 graceful shutdown: ./shutdown flushes players, then stops the servers
The stock scripts stop the game with SIGKILL (mbkill.sh runs kill -9) and
'./reboot' only calls mbrestart.sh, so anything still parked in a character's
deferred database job is thrown away: experience is written five minutes after
it is earned and stats/skills thirty seconds after they change
(engine.jobs.DatabaseUpdateJob). PlayerCharacter.updateDatabase() is an empty
stub, so there was no write-out path at all.

Added engine.gameManager.GracefulShutdown:
  flushAllPlayers()      - writes skills/powers, stat modifiers and experience
                           for every online character
  announce(String)       - server wide flash message
  registerShutdownHook() - flush on an orderly SIGTERM (SIGKILL cannot be
                           intercepted by design)
  gracefulStop(int)      - countdown, flush, then stop the login and world
                           servers

Added the './shutdown [seconds]' dev command (engine.devcmd.cmds.ShutdownCmd,
default 60s, ADMIN only like every other dev command), registered together with
the shutdown hook in WorldServer.main and LoginServer.main.

Verified on a MagicBox container: ant builds clean, the boot log shows
"shutdown hook registered for WorldServer"/"LoginServer", and kill -TERM on the
world server logs "WorldServer is terminating, flushing player data" ->
"flush finished, saved=0 failed=0" -> clean exit.
2026-10-10 13:47:16 +08:00
MagicBot 1ee80f9697 Bugfix in console port output. 2023-08-11 09:44:16 -04:00
MagicBot 43090a9bd1 Support for the widest array of network configurations. Auto-configure as best we can. 2023-07-23 12:58:40 -04:00
MagicBot 9bbdef224d Project cleanup pre merge. 2023-07-15 09:23:48 -04:00
MagicBot f8c8d7244e Moved member to ConfigManager. 2023-06-07 14:53:15 -04:00
MagicBot b6ce3b7ee9 Already logged when connection manager is created. 2023-06-07 14:32:01 -04:00
MagicBot 48aef2ef01 Network autoconfig now uses eth0 or default outgoing ip route. 2023-06-07 14:11:54 -04:00
MagicBot b9db6e8dc6 Members moved to WorldServer.
Root object no longer read from config.
2023-06-07 13:37:43 -04:00
MagicBot d0287ba94e Login should fail fast. 2023-05-25 14:55:49 -04:00
MagicBot 0e4490576a Game uses hikaricp for all connection pooling. Connection count set dynamically. 2023-05-20 09:39:23 -04:00
MagicBot ea34418f2d Cleanup of duplicate errant guild definitions. 2023-01-19 16:22:37 -05:00
MagicBot ad4678ab3c Version info pulled from config. 2022-06-06 03:26:34 -04:00
MagicBot 24057e6412 Logging when network autoconfig occurs 2022-05-03 12:23:45 -04:00
MagicBot a59dbdc4e1 Fixes bug where public_addr was autoconfigured irrespective of not being 0.0.0.0 2022-05-03 12:02:05 -04:00
MagicBot bbfdde57a3 Initial Repository Push 2022-04-30 09:41:17 -04:00