static int do_restart(const std::vector<std::string>& args) { Service* svc = ServiceManager::GetInstance().FindServiceByName(args[1]); if (!svc) { ERROR("do_restart: Service %s not found\n", args[1].c_str()); return -1; } svc->Restart(); return 0; }
static void msg_restart(const std::string& name) { Service* svc = ServiceManager::GetInstance().FindServiceByName(name); if (svc) { svc->Restart(); } else { ERROR("no such service '%s'\n", name.c_str()); } }
void handle_control_message(const std::string& msg, const std::string& name) { Service* svc = ServiceManager::GetInstance().FindServiceByName(name); if (svc == nullptr) { ERROR("no such service '%s'\n", name.c_str()); return; } if (msg == "start") { svc->Start(); } else if (msg == "stop") { svc->Stop(); } else if (msg == "restart") { svc->Restart(); } else { ERROR("unknown control msg '%s'\n", msg.c_str()); } }