1mod cli;
4mod host;
5mod shutdown;
6mod update;
7
8use std::process::ExitCode;
9
10use clap::Parser;
11use cli::{Cli, Command};
12use mimalloc::MiMalloc;
13
14#[used]
16static FORCE_LINK: fn() -> usize = wowlab_engine_content::force_link_generated_specs;
17
18#[global_allocator]
19static GLOBAL: MiMalloc = MiMalloc;
20
21const VERSION: &str = env!("CARGO_PKG_VERSION");
22
23fn main() -> ExitCode {
24 let _logging_guard = wowlab_node::init_headless_logging();
25 let cli = Cli::parse();
26
27 match cli.command {
28 Some(Command::Update { check }) => match update::run_command(check) {
29 Ok(()) => ExitCode::SUCCESS,
30 Err(error) => {
31 error.log();
32
33 ExitCode::FAILURE
34 }
35 },
36 Some(Command::Run) | None => {
37 if !cli.no_update {
38 if let update::AutoUpdateAction::Exit(code) = update::check_and_apply() {
39 return code;
40 }
41 }
42
43 match host::run() {
44 Ok(()) => ExitCode::SUCCESS,
45 Err(error) => {
46 tracing::error!(%error, "Node startup failed");
47
48 ExitCode::FAILURE
49 }
50 }
51 }
52 }
53}