blob: 04b07c3bc6c0fe86f6a72ed88aff0113c49a238f [file] [log] [blame]
Philipp Schrader790cb542023-07-05 21:06:52 -07001#include "gflags/gflags.h"
2#include "glog/logging.h"
3
Austin Schuhe84c3ed2019-12-14 15:29:48 -08004#include "aos/events/shm_event_loop.h"
5#include "aos/init.h"
Sarah Newman45a64df2022-04-11 19:33:46 -07006#include "aos/logging/dynamic_logging.h"
Austin Schuhe84c3ed2019-12-14 15:29:48 -08007#include "aos/network/message_bridge_server_lib.h"
Austin Schuhb0e439d2023-05-15 10:55:40 -07008#include "aos/sha256.h"
Austin Schuhe84c3ed2019-12-14 15:29:48 -08009
Austin Schuhc5fa6d92022-02-25 14:36:28 -080010DEFINE_string(config, "aos_config.json", "Path to the config.");
Austin Schuha922ad02021-10-23 23:25:50 -070011DEFINE_int32(rt_priority, -1, "If > 0, run as this RT priority");
Austin Schuhe84c3ed2019-12-14 15:29:48 -080012
13namespace aos {
14namespace message_bridge {
15
16int Main() {
17 aos::FlatbufferDetachedBuffer<aos::Configuration> config =
18 aos::configuration::ReadConfig(FLAGS_config);
19
20 aos::ShmEventLoop event_loop(&config.message());
Austin Schuha922ad02021-10-23 23:25:50 -070021 if (FLAGS_rt_priority > 0) {
22 event_loop.SetRuntimeRealtimePriority(FLAGS_rt_priority);
23 }
Austin Schuhe84c3ed2019-12-14 15:29:48 -080024
Austin Schuhb0e439d2023-05-15 10:55:40 -070025 MessageBridgeServer app(&event_loop, Sha256(config.span()));
Austin Schuhe84c3ed2019-12-14 15:29:48 -080026
Sarah Newman45a64df2022-04-11 19:33:46 -070027 logging::DynamicLogging dynamic_logging(&event_loop);
28
Austin Schuhe84c3ed2019-12-14 15:29:48 -080029 // TODO(austin): Track which messages didn't make it in time and need to be
30 // logged locally and forwarded.
31
32 event_loop.Run();
33
34 return EXIT_SUCCESS;
35}
36
37} // namespace message_bridge
38} // namespace aos
39
40int main(int argc, char **argv) {
41 aos::InitGoogle(&argc, &argv);
42
43 return aos::message_bridge::Main();
44}