File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -2672,8 +2672,10 @@ ngx_http_upstream_check_status_handler(ngx_http_request_t *r)
26722672{
26732673 size_t buffer_size ;
26742674 ngx_int_t rc ;
2675+ ngx_uint_t i , all_up ;
26752676 ngx_buf_t * b ;
26762677 ngx_chain_t out ;
2678+ ngx_http_upstream_check_peer_t * peer ;
26772679 ngx_http_upstream_check_peers_t * peers ;
26782680 ngx_http_upstream_check_loc_conf_t * uclcf ;
26792681 ngx_http_upstream_check_status_ctx_t * ctx ;
@@ -2736,7 +2738,22 @@ ngx_http_upstream_check_status_handler(ngx_http_request_t *r)
27362738
27372739 ctx -> format -> output (b , peers , ctx -> flag );
27382740
2739- r -> headers_out .status = NGX_HTTP_OK ;
2741+
2742+ // check if all peers are up or not
2743+ peer = peers -> peers .elts ;
2744+ all_up = 1 ;
2745+ for (i = 0 ; i < peers -> peers .nelts ; i ++ ) {
2746+ if (peer [i ].shm -> down ) {
2747+ all_up = 0 ;
2748+ break ;
2749+ }
2750+ }
2751+
2752+ if (all_up == 1 ) {
2753+ r -> headers_out .status = NGX_HTTP_OK ;
2754+ } else {
2755+ r -> headers_out .status = NGX_HTTP_SERVICE_UNAVAILABLE ;
2756+ }
27402757 r -> headers_out .content_length_n = b -> last - b -> pos ;
27412758
27422759 if (r -> headers_out .content_length_n == 0 ) {
You can’t perform that action at this time.
0 commit comments