| 216 | } |
| 217 | |
| 218 | void service_engine::start_node(service_app_spec &app_spec) |
| 219 | { |
| 220 | std::unordered_map<int, std::string> app_name_by_port; |
| 221 | auto it = _nodes_by_app_id.find(app_spec.id); |
| 222 | if (it == _nodes_by_app_id.end()) { |
| 223 | for (auto p : app_spec.ports) { |
| 224 | // union to existing node if any port is shared |
| 225 | auto it = app_name_by_port.find(p); |
| 226 | if (it != app_name_by_port.end()) { |
| 227 | CHECK(false, |
| 228 | "network port {} usage confliction for {} vs {}, " |
| 229 | "please reconfig", |
| 230 | p, |
| 231 | it->second, |
| 232 | app_spec.full_name); |
| 233 | } |
| 234 | app_name_by_port.emplace(p, app_spec.full_name); |
| 235 | } |
| 236 | |
| 237 | auto node = std::make_shared<service_node>(app_spec); |
| 238 | error_code err = node->start(); |
| 239 | CHECK_EQ_MSG(err, ERR_OK, "service node start failed"); |
| 240 | |
| 241 | _nodes_by_app_id[node->id()] = node; |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | std::string service_engine::get_runtime_info(const std::vector<std::string> &args) |
| 246 | { |