transfer the mode's cyber modules to modules.
118 {
119
120 for (const auto &iter : mode->cyber_modules()) {
121 const std::string &module_name = iter.first;
122 const CyberModule &cyber_module = iter.second;
123
124 ACHECK(!cyber_module.dag_files().empty())
125 << "None dag file is provided for " << module_name;
126
127 Module &module = LookupOrInsert(mode->mutable_modules(), module_name, {});
128 module.set_required_for_safety(cyber_module.required_for_safety());
129
130
131
132 module.set_start_command("nohup mainboard");
133 const auto &process_group = cyber_module.process_group();
134 if (!process_group.empty()) {
135 absl::StrAppend(module.mutable_start_command(), " -p ", process_group);
136 }
137 for (const std::string &dag : cyber_module.dag_files()) {
138 absl::StrAppend(module.mutable_start_command(), " -d ", dag);
139 }
140 absl::StrAppend(module.mutable_start_command(), " &");
141
142
143 const std::string &first_dag = cyber_module.dag_files(0);
144 module.set_stop_command(absl::StrCat("pkill -f \"", first_dag, "\""));
145
146 module.mutable_process_monitor_config()->add_command_keywords("mainboard");
147 module.mutable_process_monitor_config()->add_command_keywords(first_dag);
148 }
149 mode->clear_cyber_modules();
150}