File tree 1 file changed +18
-1
lines changed
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)
2672
2672
{
2673
2673
size_t buffer_size ;
2674
2674
ngx_int_t rc ;
2675
+ ngx_uint_t i , all_up ;
2675
2676
ngx_buf_t * b ;
2676
2677
ngx_chain_t out ;
2678
+ ngx_http_upstream_check_peer_t * peer ;
2677
2679
ngx_http_upstream_check_peers_t * peers ;
2678
2680
ngx_http_upstream_check_loc_conf_t * uclcf ;
2679
2681
ngx_http_upstream_check_status_ctx_t * ctx ;
@@ -2736,7 +2738,22 @@ ngx_http_upstream_check_status_handler(ngx_http_request_t *r)
2736
2738
2737
2739
ctx -> format -> output (b , peers , ctx -> flag );
2738
2740
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
+ }
2740
2757
r -> headers_out .content_length_n = b -> last - b -> pos ;
2741
2758
2742
2759
if (r -> headers_out .content_length_n == 0 ) {
You can’t perform that action at this time.
0 commit comments