blob: ec3cdc42fa45a3aabaa6d0f740ac68083dcbb60d [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"
Austin Schuhb0e439d2023-05-15 10:55:40 -07005#include "aos/sha256.h"
Austin Schuhe84c3ed2019-12-14 15:29:48 -08006#include "gflags/gflags.h"
7#include "glog/logging.h"
8
Austin Schuhc5fa6d92022-02-25 14:36:28 -08009DEFINE_string(config, "aos_config.json", "Path to the config.");
Austin Schuha922ad02021-10-23 23:25:50 -070010DEFINE_int32(rt_priority, -1, "If > 0, run as this RT priority");
Austin Schuhe84c3ed2019-12-14 15:29:48 -080011
12namespace aos {
13namespace message_bridge {
14
15int Main() {
16 aos::FlatbufferDetachedBuffer<aos::Configuration> config =
17 aos::configuration::ReadConfig(FLAGS_config);
18
19 aos::ShmEventLoop event_loop(&config.message());
Austin Schuha922ad02021-10-23 23:25:50 -070020 if (FLAGS_rt_priority > 0) {
21 event_loop.SetRuntimeRealtimePriority(FLAGS_rt_priority);
22 }
Austin Schuhe84c3ed2019-12-14 15:29:48 -080023
Austin Schuhb0e439d2023-05-15 10:55:40 -070024 MessageBridgeServer app(&event_loop, Sha256(config.span()));
Austin Schuhe84c3ed2019-12-14 15:29:48 -080025
Sarah Newman45a64df2022-04-11 19:33:46 -070026 logging::DynamicLogging dynamic_logging(&event_loop);
27
Austin Schuhe84c3ed2019-12-14 15:29:48 -080028 // TODO(austin): Track which messages didn't make it in time and need to be
29 // logged locally and forwarded.
30
31 event_loop.Run();
32
33 return EXIT_SUCCESS;
34}
35
36} // namespace message_bridge
37} // namespace aos
38
39int main(int argc, char **argv) {
40 aos::InitGoogle(&argc, &argv);
41
42 return aos::message_bridge::Main();
43}