Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add back supervisord support

  • Loading branch information...
commit db5ca8ea5c6d706e942e5a7c03fc8fc5c08d8bef 1 parent fda3153
Jack Lindamood authored
Showing with 24 additions and 0 deletions.
  1. +21 −0 ngx_http_healthcheck_module.c
  2. +3 −0  sample_ngx_config.conf
21 ngx_http_healthcheck_module.c
View
@@ -9,6 +9,12 @@
#include <ngx_core.h>
#include <ngx_http.h>
#include <ngx_http_healthcheck_module.h>
+#ifdef NGX_SUPERVISORD_MODULE
+#include <ngx_supervisord.h>
+#if (NGX_SUPERVISORD_API_VERSION != 2)
+ #error "ngx_http_upstream_fair_module requires NGX_SUPERVISORD_API v2"
+#endif
+#endif
#if (!NGX_HAVE_ATOMIC_OPS)
#error "Healthcheck module only works with atomic ops"
@@ -264,6 +270,9 @@ ngx_module_t ngx_http_healthcheck_module = {
void ngx_http_healthcheck_mark_finished(ngx_http_healthcheck_status_t *stat) {
+#ifdef NGX_SUPERVISORD_MODULE
+ ngx_http_upstream_rr_peers_t *peers = stat->conf->peer.data;
+#endif
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, stat->health_ev.log, 0,
"healthcheck: Finished %V, state %d", &stat->peer->name,
stat->state);
@@ -272,6 +281,12 @@ void ngx_http_healthcheck_mark_finished(ngx_http_healthcheck_status_t *stat) {
stat->shm->last_down = 0;
stat->shm->concurrent = 1;
stat->shm->since = ngx_current_msec;
+#ifdef NGX_SUPERVISORD_MODULE
+ (void) ngx_supervisord_execute(stat->conf,
+ NGX_SUPERVISORD_CMD_START,
+ peers->peer[stat->index].onumber,
+ NULL);
+#endif
} else {
stat->shm->concurrent++;
}
@@ -282,6 +297,12 @@ void ngx_http_healthcheck_mark_finished(ngx_http_healthcheck_status_t *stat) {
stat->shm->last_down = 1;
stat->shm->concurrent = 1;
stat->shm->since = ngx_current_msec;
+#ifdef NGX_SUPERVISORD_MODULE
+ (void) ngx_supervisord_execute(stat->conf,
+ NGX_SUPERVISORD_CMD_STOP,
+ peers->peer[stat->index].onumber,
+ NULL);
+#endif
}
}
if (stat->shm->concurrent >= stat->conf->health_failcount) {
3  sample_ngx_config.conf
View
@@ -25,6 +25,9 @@ http {
healthcheck_expected 'I_AM_ALIVE';
# Important: HTTP/1.0
healthcheck_send "GET /health HTTP/1.0" 'Host: www.mysite.com';
+ # Optional supervisord module support
+ #supervisord none;
+ #supervisord_inherit_backend_status;
}
server {
Please sign in to comment.
Something went wrong with that request. Please try again.