File tree Expand file tree Collapse file tree 3 files changed +27
-3
lines changed Expand file tree Collapse file tree 3 files changed +27
-3
lines changed Original file line number Diff line number Diff line change 2424#include " http/http_headers.h"
2525#include " http/http_request.h"
2626#include " http/http_status.h"
27+ #include " runtime/exec_env.h"
2728
2829namespace doris {
2930
3031const static std::string HEADER_JSON = " application/json" ;
3132
3233void HealthAction::handle (HttpRequest* req) {
34+ std::string status;
35+ std::string msg;
36+ HttpStatus st;
37+ if (!doris::k_is_server_ready) {
38+ status = " Server is not available" ;
39+ msg = " Server is not ready" ;
40+ st = HttpStatus::SERVICE_UNAVAILABLE;
41+ } else if (doris::k_doris_exit) {
42+ status = " Server is not available" ;
43+ msg = " Server is shutting down" ;
44+ st = HttpStatus::SERVICE_UNAVAILABLE;
45+ } else {
46+ status = " OK" ;
47+ msg = " OK" ;
48+ st = HttpStatus::OK;
49+ }
50+
3351 std::stringstream ss;
3452 ss << " {" ;
35- ss << " \" status\" : \" OK \" ," ;
36- ss << " \" msg\" : \" To Be Added \" " ;
53+ ss << " \" status\" : \" " << status << " \" ," ;
54+ ss << " \" msg\" : \" " << msg << " \" " ;
3755 ss << " }" ;
3856 std::string result = ss.str ();
3957
4058 req->add_output_header (HttpHeaders::CONTENT_TYPE, HEADER_JSON.c_str ());
41- HttpChannel::send_reply (req, HttpStatus::OK , result);
59+ HttpChannel::send_reply (req, st , result);
4260}
4361
4462} // end namespace doris
Original file line number Diff line number Diff line change @@ -133,7 +133,10 @@ class IndexPolicyMgr;
133133struct SyncRowsetStats ;
134134class DeleteBitmapAggCache ;
135135
136+ // set to true when BE is shutting down
136137inline bool k_doris_exit = false ;
138+ // set to true after BE start ready
139+ inline bool k_is_server_ready = false ;
137140
138141// Execution environment for queries/plan fragments.
139142// Contains all required global structures, and handles to
Original file line number Diff line number Diff line change @@ -602,12 +602,15 @@ int main(int argc, char** argv) {
602602
603603 exec_env->storage_engine ().notify_listeners ();
604604
605+ doris::k_is_server_ready = true ;
606+
605607 while (!doris::k_doris_exit) {
606608#if defined(LEAK_SANITIZER)
607609 __lsan_do_leak_check ();
608610#endif
609611 sleep (3 );
610612 }
613+ doris::k_is_server_ready = false ;
611614 LOG (INFO) << " Doris main exiting." ;
612615#if defined(LLVM_PROFILE)
613616 __llvm_profile_write_file ();
You can’t perform that action at this time.
0 commit comments