From ee05f4f04d2e1d810bcd6d92cf78118d0722edc4 Mon Sep 17 00:00:00 2001 From: Mike Dilger Date: Thu, 30 Nov 2023 16:00:00 +1300 Subject: [PATCH] SETUP_AND_SHUTDOWN process doc --- docs/SETUP_AND_SHUTDOWN.md | 48 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 docs/SETUP_AND_SHUTDOWN.md diff --git a/docs/SETUP_AND_SHUTDOWN.md b/docs/SETUP_AND_SHUTDOWN.md new file mode 100644 index 00000000..eef505ee --- /dev/null +++ b/docs/SETUP_AND_SHUTDOWN.md @@ -0,0 +1,48 @@ +# Setup and Shutdown + +This may change, but this is approximately the order of events. + +- bin::main() + - setup logging + - lib::init() + - storage::init() + - trigger database into existence + - migrate + - signer::init() + - load from settings in storage + - deletation init + - setup wait-for-login state + - setup async runtime + - optionally handle command-line command and exit, else + - spawn (two threads as below) + +- spawn-thread + - lib::run() + - overlord::run() + - maybe wait-for-login (the UI has to do it) + - start fetcher + - start People tasks + - start relay picker + - pick relays + - subscribe discover + - subscribe outbox + - subscribe inbox + - loop + - Get and handle messages + - or if shutdown variable is set, exit this loop + - storage::sync() + - set shutdown variable + - message minions to shutdown + - wait for minions to shutdown + - end of spawn-thread + +- main-thread + - ui::run() + - Setup and run the UI + - if wait-for-login, prompt for password and login + - once logged in, indicate such so the overlord can start, and run UI as normal + - If shutdown variable is set, exit + - Signal overlord to shutdown + - Wait for spawn-thread to end + - lib::shutdown() + - storage::sync()