MCPcopy Create free account
hub / github.com/TelegramMessenger/cocoon / main

Function main

runners/ClientRunner.cpp:12–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10}
11
12int main(int argc, char **argv) {
13 SET_VERBOSITY_LEVEL(verbosity_INFO);
14
15 td::set_default_failure_signal_handler().ensure();
16
17 std::string engine_config_filename = "client-config.json";
18 std::string pseudo_config_filename = "";
19
20 td::OptionParser option_parser;
21 option_parser.set_description("client runner: run COCOON client");
22 option_parser.add_option('c', "config", "client config", [&](td::Slice opt) { engine_config_filename = opt.str(); });
23 option_parser.add_checked_option('v', "verbosity", "set verbosity level", [&](td::Slice opt) -> td::Status {
24 TRY_RESULT(level, td::to_integer_safe<td::int32>(opt));
25 SET_VERBOSITY_LEVEL(level);
26 return td::Status::OK();
27 });
28 option_parser.add_option('C', "disable-ton", "disable ton and use fake ton config",
29 [&](td::Slice opt) { pseudo_config_filename = opt.str(); });
30 option_parser.run(argc, argv, 0).ensure();
31
32 td::actor::set_debug(true);
33 td::actor::Scheduler scheduler({7});
34
35 td::actor::ActorOwn<cocoon::ClientRunner> client_runner;
36
37 scheduler.run_in_context([&] {
38 client_runner =
39 td::actor::create_actor<cocoon::ClientRunner>("client", std::move(engine_config_filename), &scheduler);
40 td::actor::send_lambda(client_runner, [&]() {
41 auto &ptr = client_runner.get_actor_unsafe();
42 if (pseudo_config_filename.size() > 0) {
43 ptr.disable_ton(pseudo_config_filename);
44 }
45 ptr.initialize();
46 });
47 });
48
49 while (scheduler.run(1)) {
50 if (need_stats_flag.exchange(false)) {
51 dump_stats();
52 }
53 if (need_scheduler_status_flag.exchange(false)) {
54 LOG(ERROR) << "DUMPING SCHEDULER STATISTICS";
55 td::StringBuilder sb;
56 scheduler.get_debug().dump(sb);
57 LOG(ERROR) << "GOT SCHEDULER STATISTICS\n" << sb.as_cslice();
58 }
59 if (rotate_logs_flags.exchange(false)) {
60 if (td::log_interface) {
61 td::log_interface->rotate();
62 }
63 }
64 }
65
66 return 0;
67}

Callers

nothing calls this directly

Calls 5

disable_tonMethod · 0.80
as_csliceMethod · 0.80
dump_statsFunction · 0.70
runMethod · 0.45
initializeMethod · 0.45

Tested by

no test coverage detected