diff options
| author | Rutger Broekhoff | 2026-08-28 22:17:10 +0200 |
|---|---|---|
| committer | Rutger Broekhoff | 2026-08-28 22:17:10 +0200 |
| commit | 70643a9e4821bd11c3f363f1708fe420965467d1 (patch) | |
| tree | 65572b58e247248846628940a2aaca197a15d784 /server/src/main.cpp | |
| parent | 173cd34bdd0717d3f4beeac76b3296ecd46ada0d (diff) | |
| download | routemon-70643a9e4821bd11c3f363f1708fe420965467d1.tar.gz routemon-70643a9e4821bd11c3f363f1708fe420965467d1.zip | |
Format again
Diffstat (limited to 'server/src/main.cpp')
| -rw-r--r-- | server/src/main.cpp | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/server/src/main.cpp b/server/src/main.cpp index 0a7a784..2957808 100644 --- a/server/src/main.cpp +++ b/server/src/main.cpp | |||
| @@ -21,9 +21,9 @@ auto real_main(std::span<char const*> args) -> exit_status | |||
| 21 | if (args.size() != 2) | 21 | if (args.size() != 2) |
| 22 | { | 22 | { |
| 23 | l.error( | 23 | l.error( |
| 24 | "Fatal: expected exactly one argument (the configuration file " | 24 | "Fatal: expected exactly one argument (the configuration file " |
| 25 | "location), got {}", | 25 | "location), got {}", |
| 26 | args.size() - 1); | 26 | args.size() - 1); |
| 27 | return exit_status::bad_usage; | 27 | return exit_status::bad_usage; |
| 28 | } | 28 | } |
| 29 | auto const* config_filename = args[1]; | 29 | auto const* config_filename = args[1]; |
| @@ -31,10 +31,10 @@ auto real_main(std::span<char const*> args) -> exit_status | |||
| 31 | auto lgen = routemon::locale::make_generator(); | 31 | auto lgen = routemon::locale::make_generator(); |
| 32 | auto default_locale = lgen->generate("en_US.UTF-8"); | 32 | auto default_locale = lgen->generate("en_US.UTF-8"); |
| 33 | auto locales = { | 33 | auto locales = { |
| 34 | default_locale, | 34 | default_locale, |
| 35 | lgen->generate("nl_NL.UTF-8"), | 35 | lgen->generate("nl_NL.UTF-8"), |
| 36 | lgen->generate("de_DE.UTF-8"), | 36 | lgen->generate("de_DE.UTF-8"), |
| 37 | lgen->generate("en_GB.UTF-8"), | 37 | lgen->generate("en_GB.UTF-8"), |
| 38 | }; | 38 | }; |
| 39 | auto lsel = routemon::locale::selector{locales, default_locale, lgen}; | 39 | auto lsel = routemon::locale::selector{locales, default_locale, lgen}; |
| 40 | 40 | ||
| @@ -48,7 +48,7 @@ auto real_main(std::span<char const*> args) -> exit_status | |||
| 48 | catch (std::exception const& e) | 48 | catch (std::exception const& e) |
| 49 | { | 49 | { |
| 50 | l.with("filename", std::string_view{config_filename}) | 50 | l.with("filename", std::string_view{config_filename}) |
| 51 | .error("Failed to load configuration: {}", e.what()); | 51 | .error("Failed to load configuration: {}", e.what()); |
| 52 | return exit_status::failure; | 52 | return exit_status::failure; |
| 53 | } | 53 | } |
| 54 | sink->set_level(config.logger.level); | 54 | sink->set_level(config.logger.level); |
| @@ -68,19 +68,19 @@ auto real_main(std::span<char const*> args) -> exit_status | |||
| 68 | catch (std::exception const& e) | 68 | catch (std::exception const& e) |
| 69 | { | 69 | { |
| 70 | l.with("filename", config.database.sqlite3_filename) | 70 | l.with("filename", config.database.sqlite3_filename) |
| 71 | .error("Failed to open database: {}", e.what()); | 71 | .error("Failed to open database: {}", e.what()); |
| 72 | return exit_status::failure; | 72 | return exit_status::failure; |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | l.with("filename", config.situations.datex2_filename) | 75 | l.with("filename", config.situations.datex2_filename) |
| 76 | .info("Loading situations"); | 76 | .info("Loading situations"); |
| 77 | auto const before_load = chrono::steady_clock::now(); | 77 | auto const before_load = chrono::steady_clock::now(); |
| 78 | auto d2loader = routemon::datex2::loader{}; | 78 | auto d2loader = routemon::datex2::loader{}; |
| 79 | auto pub = routemon::datex2::situation_publication{}; | 79 | auto pub = routemon::datex2::situation_publication{}; |
| 80 | try | 80 | try |
| 81 | { | 81 | { |
| 82 | pub = | 82 | pub = |
| 83 | d2loader.load_situation_publication(config.situations.datex2_filename); | 83 | d2loader.load_situation_publication(config.situations.datex2_filename); |
| 84 | } | 84 | } |
| 85 | catch (std::exception const& e) | 85 | catch (std::exception const& e) |
| 86 | { | 86 | { |
| @@ -91,9 +91,9 @@ auto real_main(std::span<char const*> args) -> exit_status | |||
| 91 | { | 91 | { |
| 92 | auto const& warns = d2loader.warnings(); | 92 | auto const& warns = d2loader.warnings(); |
| 93 | l.warn( | 93 | l.warn( |
| 94 | "Encountered {} unique warnings while loading DATEX II situations " | 94 | "Encountered {} unique warnings while loading DATEX II situations " |
| 95 | "publication", | 95 | "publication", |
| 96 | warns.size()); | 96 | warns.size()); |
| 97 | auto i = 0uz; | 97 | auto i = 0uz; |
| 98 | for (auto it = warns.begin(); it != warns.end(); | 98 | for (auto it = warns.begin(); it != warns.end(); |
| 99 | it = warns.upper_bound(*it)) | 99 | it = warns.upper_bound(*it)) |
| @@ -108,12 +108,12 @@ auto real_main(std::span<char const*> args) -> exit_status | |||
| 108 | malloc_trim(0); | 108 | malloc_trim(0); |
| 109 | auto const after_load = chrono::steady_clock::now(); | 109 | auto const after_load = chrono::steady_clock::now(); |
| 110 | auto const dur_load = | 110 | auto const dur_load = |
| 111 | chrono::duration_cast<chrono::milliseconds>(after_load - before_load); | 111 | chrono::duration_cast<chrono::milliseconds>(after_load - before_load); |
| 112 | l.info("Loading situations finished in {}", dur_load); | 112 | l.info("Loading situations finished in {}", dur_load); |
| 113 | 113 | ||
| 114 | auto handler = routemon::api::handler{l, std::move(pub)}; | 114 | auto handler = routemon::api::handler{l, std::move(pub)}; |
| 115 | auto http_server = | 115 | auto http_server = |
| 116 | routemon::srv::server{l, std::move(lsel), std::move(handler)}; | 116 | routemon::srv::server{l, std::move(lsel), std::move(handler)}; |
| 117 | http_server.spawn(ioc); | 117 | http_server.spawn(ioc); |
| 118 | ioc.run(); | 118 | ioc.run(); |
| 119 | 119 | ||
| @@ -129,9 +129,7 @@ auto main(int argc, char* argv[]) -> int | |||
| 129 | return EXIT_FAILURE; | 129 | return EXIT_FAILURE; |
| 130 | } | 130 | } |
| 131 | auto res = real_main( | 131 | auto res = real_main( |
| 132 | std::span{ | 132 | std::span{const_cast<char const**>(argv), static_cast<std::size_t>(argc)}); |
| 133 | const_cast<char const**>(argv), static_cast<std::size_t>(argc) | ||
| 134 | }); | ||
| 135 | switch (res) | 133 | switch (res) |
| 136 | { | 134 | { |
| 137 | case exit_status::failure: | 135 | case exit_status::failure: |