blob: 3b5d30bbb4bded1471498eef946f9010a8ec2e15 [file] [log] [blame]
Austin Schuhe84c3ed2019-12-14 15:29:48 -08001#include "aos/events/shm_event_loop.h"
2#include "aos/init.h"
Sarah Newman45a64df2022-04-11 19:33:46 -07003#include "aos/logging/dynamic_logging.h"
Austin Schuhe84c3ed2019-12-14 15:29:48 -08004#include "aos/network/message_bridge_server_lib.h"
5#include "gflags/gflags.h"
6#include "glog/logging.h"
7
Austin Schuhc5fa6d92022-02-25 14:36:28 -08008DEFINE_string(config, "aos_config.json", "Path to the config.");
Austin Schuha922ad02021-10-23 23:25:50 -07009DEFINE_int32(rt_priority, -1, "If > 0, run as this RT priority");
Austin Schuhe84c3ed2019-12-14 15:29:48 -080010
11namespace aos {
12namespace message_bridge {
13
14int Main() {
15 aos::FlatbufferDetachedBuffer<aos::Configuration> config =
16 aos::configuration::ReadConfig(FLAGS_config);
17
18 aos::ShmEventLoop event_loop(&config.message());
Austin Schuha922ad02021-10-23 23:25:50 -070019 if (FLAGS_rt_priority > 0) {
20 event_loop.SetRuntimeRealtimePriority(FLAGS_rt_priority);
21 }
Austin Schuhe84c3ed2019-12-14 15:29:48 -080022
23 MessageBridgeServer app(&event_loop);
24
Sarah Newman45a64df2022-04-11 19:33:46 -070025 logging::DynamicLogging dynamic_logging(&event_loop);
26
Austin Schuhe84c3ed2019-12-14 15:29:48 -080027 // TODO(austin): Track which messages didn't make it in time and need to be
28 // logged locally and forwarded.
29
30 event_loop.Run();
31
32 return EXIT_SUCCESS;
33}
34
35} // namespace message_bridge
36} // namespace aos
37
38int main(int argc, char **argv) {
39 aos::InitGoogle(&argc, &argv);
40
41 return aos::message_bridge::Main();
42}