Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions examples/server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4525,6 +4525,7 @@ int main(int argc, char ** argv) {

// run the HTTP server in a thread
std::thread t([&]() { svr->listen_after_bind(); });
t.detach();
svr->wait_until_ready();

LOG_INF("%s: HTTP server is listening, hostname: %s, port: %d, http threads: %d\n", __func__, params.hostname.c_str(), params.port, params.n_threads_http);
Expand All @@ -4534,9 +4535,8 @@ int main(int argc, char ** argv) {

if (!ctx_server.load_model(params)) {
clean_up();
// t.join(); // FIXME: see below
LOG_ERR("%s: exiting due to model loading error\n", __func__);
return 1;
exit(1);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you explain why return 1 doesn't work here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because the thread is detached

}

ctx_server.init();
Expand Down Expand Up @@ -4582,7 +4582,6 @@ int main(int argc, char ** argv) {
ctx_server.queue_tasks.start_loop();

clean_up();
// t.join(); // FIXME: http thread may stuck if there is an on-going request. we don't need to care about this for now as the HTTP connection will already be closed at this point, but it's better to fix this

return 0;

exit(0);
}