98bool Init(
const char* binary_name,
const std::string& dag_info) {
99 const char* apollo_runtime_path = std::getenv(
"APOLLO_RUNTIME_PATH");
100 if (apollo_runtime_path !=
nullptr) {
101 if (std::filesystem::is_directory(
102 std::filesystem::status(apollo_runtime_path))) {
103 std::filesystem::current_path(apollo_runtime_path);
107 std::lock_guard<std::mutex> lg(g_mutex);
112 InitLogger(binary_name);
113 auto thread =
const_cast<std::thread*
>(async_logger->LogThread());
118 if (!g_atexit_registered) {
120 AERROR <<
"Register exit handle failed";
123 AINFO <<
"Register exit handle succ.";
124 g_atexit_registered =
true;
128 auto global_data = GlobalData::Instance();
129 if (global_data->IsMockTimeMode()) {
130 auto node_name = kClockNode + std::to_string(getpid());
131 clock_node = std::unique_ptr<Node>(
new Node(node_name));
133 [](
const std::shared_ptr<const apollo::cyber::proto::Clock>& msg) {
134 if (msg->has_clock()) {
135 Clock::Instance()->SetNow(
Time(msg->clock()));
141 if (dag_info !=
"") {
142 std::string dump_path;
143 if (dag_info.length() > 200) {
144 std::string truncated = dag_info.substr(0, 200);
145 dump_path =
common::GetEnv(
"APOLLO_ENV_WORKROOT",
"/apollo") +
"/dumps/" +
148 dump_path =
common::GetEnv(
"APOLLO_ENV_WORKROOT",
"/apollo") +
"/dumps/" +
151 google::SetCommandLineOption(
"bvar_dump_file", dump_path.c_str());
153 statistics::Statistics::Instance()->DisableChanVar();
155 google::SetCommandLineOption(
"bvar_dump_exclude",
"*qps");
156 google::SetCommandLineOption(
"bvar_dump",
"true");