Jump to content

API: Shutdown: Difference between revisions

From fCraft Wiki
No edit summary
No edit summary
 
Line 22: Line 22:


==Termination==
==Termination==
:ServerGUI does a clean shutdown on <code>WM_QUIT</code>/<code>WM_CLOSE</code> (<code>SIGTERM</code> on *nix). ServerCLI handles Ctrl+C and Ctrl+Break interrupts, but quits abruptly signals.
:ServerGUI does a clean shutdown on <code>WM_QUIT</code>/<code>WM_CLOSE</code> (<code>SIGTERM</code> on *nix). ServerCLI does a clean shutdown on Ctrl+C or Ctrl+Break, but does not handle signals. CLR does not provide a low-level way of handling signals/interrupts, but WinForms applications handle it internally, and call the Form.Closing event. Command-line applications just die.
:CLR does not provide a low-level way of handling signals/interrupts, but WinForms applications handle it internally, and call the Form.Closing event. Command-line applications just die.


[[Category:Dev]]
[[Category:Dev]]

Latest revision as of 00:07, 27 August 2012

When an fCraft server is being shut down, the following sequence of events takes place:

  1. Server.Shutdown
    1. Cancels any previous shutdown attempt.
    2. Verifies ShutdownParams
    3. Announces shutdown and starts the countdown.

After the timer elapses, Server.ShutdownNow (internal) is called on a separate thread:

  1. Server.ShutdownNow
    1. Server.ShutdownBegan
    2. Scheduler clears the list of tasks, and prevents future tasks from being added. Current task is allowed to finish.
    3. Stop listening for connections
    4. Kick all players, allow 1000ms to deliver the kick packet
    5. Disconnect IRC
    6. Save and unload all worlds
    7. Scheduler waits for current task to finish (if it is still running).
    8. Save and unload PlayerDB
    9. Save and unload IPBanList
    10. Set Environment.ExitCode to the appropriate ShutdownReason code.
    11. Server.ShutdownEnded

Termination

ServerGUI does a clean shutdown on WM_QUIT/WM_CLOSE (SIGTERM on *nix). ServerCLI does a clean shutdown on Ctrl+C or Ctrl+Break, but does not handle signals. CLR does not provide a low-level way of handling signals/interrupts, but WinForms applications handle it internally, and call the Form.Closing event. Command-line applications just die.