make command not block.
Some checks failed
Deploy Docker Images / Build dockerfile and Server deploy (push) Successful in 18s
Deploy / Build (push) Failing after 3m53s

This commit is contained in:
amass 2024-11-10 20:23:00 +08:00
parent 83b0ff4369
commit e833d990db
2 changed files with 88 additions and 80 deletions

View File

@ -349,7 +349,13 @@ void Application::requetExit() {
nng_log_set_logger(nng_stderr_logger); nng_log_set_logger(nng_stderr_logger);
LOG(info) << "send exit request to program."; LOG(info) << "send exit request to program.";
Nng::Socket request(Nng::Request); Nng::Socket request(Nng::Request);
request.dial(IpcUrl); request.setOption(Nng::RecvTimeout, std::chrono::milliseconds(2000));
std::error_code error;
request.dial(IpcUrl, error);
if (error) {
LOG(error) << error.message();
return;
}
boost::json::object object; boost::json::object object;
object["command"] = "exit"; object["command"] = "exit";

View File

@ -32,10 +32,6 @@ int main(int argc, char const *argv[]) {
try { try {
boost::program_options::store(boost::program_options::parse_command_line(argc, argv, description), values); boost::program_options::store(boost::program_options::parse_command_line(argc, argv, description), values);
boost::program_options::notify(values); boost::program_options::notify(values);
} catch (const boost::program_options::invalid_command_line_syntax &e) {
LOG(fatal) << e.what();
std::exit(-1);
}
if (values.count("help")) { if (values.count("help")) {
std::cout << description << std::endl; std::cout << description << std::endl;
@ -115,4 +111,10 @@ int main(int argc, char const *argv[]) {
boost::system::error_code perror; boost::system::error_code perror;
proxy->run(perror); proxy->run(perror);
return application->exec(); return application->exec();
} catch (const boost::program_options::invalid_command_line_syntax &e) {
LOG(fatal) << e.what();
std::exit(-1);
} catch (const std::exception &e) {
LOG(error) << e.what();
}
} }