commit 91132dd: Merge pull request #3788 from mrueg/healthcheck
GitHub
noreply at github.com
Wed Jul 21 10:07:06 UTC 2021
Author: Vsevolod Stakhov
Date: 2021-07-21 11:04:36 +0100
URL: https://github.com/rspamd/rspamd/commit/91132dd0c187bd422c159ad3f0656e476f99a9b2 (HEAD -> master)
Merge pull request #3788 from mrueg/healthcheck
Add health and readiness checks
src/controller.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
src/libserver/cfg_file.h | 5 +++--
2 files changed, 51 insertions(+), 2 deletions(-)
diff --combined src/controller.c
index e62e42e00,e209d9320..161ab8f1a
--- a/src/controller.c
+++ b/src/controller.c
@@@ -46,11 -46,13 +46,13 @@@
#define PATH_GET_MAP "/getmap"
#define PATH_GRAPH "/graph"
#define PATH_PIE_CHART "/pie"
+ #define PATH_HEALTHY "/healthy"
#define PATH_HISTORY "/history"
#define PATH_HISTORY_RESET "/historyreset"
#define PATH_LEARN_SPAM "/learnspam"
#define PATH_LEARN_HAM "/learnham"
#define PATH_METRICS "/metrics"
+ #define PATH_READY "/ready"
#define PATH_SAVE_ACTIONS "/saveactions"
#define PATH_SAVE_SYMBOLS "/savesymbols"
#define PATH_SAVE_MAP "/savemap"
@@@ -1579,6 -1581,46 +1581,46 @@@ err
rspamd_controller_send_error (conn_ent, 500, "Internal error");
}
+ /*
+ * Healthy command handler:
+ * request: /healthy
+ * headers: Password
+ * reply: json {"success":true}
+ */
+ static int
+ rspamd_controller_handle_healthy (struct rspamd_http_connection_entry *conn_ent,
+ struct rspamd_http_message *msg)
+ {
+ struct rspamd_controller_session *session = conn_ent->ud;
+
+ if (!rspamd_controller_check_password (conn_ent, session, msg, FALSE)) {
+ return 0;
+ }
+
+ rspamd_controller_send_string (conn_ent, "{\"success\":true}");
+ return 0;
+ }
+
+ /*
+ * Ready command handler:
+ * request: /ready
+ * headers: Password
+ * reply: json {"success":true} or {"error":"error message"}
+ */
+ static int
+ rspamd_controller_handle_ready (struct rspamd_http_connection_entry *conn_ent,
+ struct rspamd_http_message *msg)
+ {
+ struct rspamd_controller_session *session = conn_ent->ud;
+
+ if (!rspamd_controller_check_password (conn_ent, session, msg, FALSE)) {
+ return 0;
+ }
+
+ rspamd_controller_send_string (conn_ent, "{\"success\":true}");
+ return 0;
+ }
+
/*
* History command handler:
* request: /history
@@@ -2764,7 -2806,7 +2806,7 @@@ rspamd_controller_metrics_fin_task (voi
ucl_object_toint (ucl_object_lookup (top, "control_connections")));
rspamd_printf_fstring (&output, "pools_allocated %L\n",
ucl_object_toint (ucl_object_lookup (top, "pools_allocated")));
- rspamd_printf_fstring (&output, "pools_freed %" PRId64 "\n",
+ rspamd_printf_fstring (&output, "pools_freed %L\n",
ucl_object_toint (ucl_object_lookup (top, "pools_freed")));
rspamd_printf_fstring (&output, "bytes_allocated %L\n",
ucl_object_toint (ucl_object_lookup (top, "bytes_allocated")));
@@@ -3894,6 -3936,12 +3936,12 @@@ start_controller_worker (struct rspamd_
rspamd_http_router_add_path (ctx->http,
PATH_GRAPH,
rspamd_controller_handle_graph);
+ rspamd_http_router_add_path (ctx->http,
+ PATH_HEALTHY,
+ rspamd_controller_handle_healthy);
+ rspamd_http_router_add_path (ctx->http,
+ PATH_READY,
+ rspamd_controller_handle_ready);
rspamd_http_router_add_path (ctx->http,
PATH_HISTORY,
rspamd_controller_handle_history);
diff --combined src/libserver/cfg_file.h
index 6ee407332,fb35e0165..4d865e273
--- a/src/libserver/cfg_file.h
+++ b/src/libserver/cfg_file.h
@@@ -419,7 -419,7 +419,7 @@@ struct rspamd_config
ucl_object_t *config_comments; /**< comments saved from the config */
ucl_object_t *doc_strings; /**< documentation strings for config options */
GPtrArray *c_modules; /**< list of C modules */
- GHashTable *composite_symbols; /**< hash of composite symbols indexed by its name */
+ void *composites_manager; /**< hash of composite symbols indexed by its name */
GList *classifiers; /**< list of all classifiers defined */
GList *statfiles; /**< list of all statfiles in config file order */
GHashTable *classifiers_symbols; /**< hashtable indexed by symbol name of classifiers */
@@@ -481,12 -481,13 +481,13 @@@
GList *classify_headers; /**< list of headers using for statistics */
struct module_s **compiled_modules; /**< list of compiled C modules */
- struct worker_s **compiled_workers; /**< list of compiled C modules */struct rspamd_log_format *log_format; /**< parsed log format */
+ struct worker_s **compiled_workers; /**< list of compiled C modules */
+ struct rspamd_log_format *log_format; /**< parsed log format */
gchar *log_format_str; /**< raw log format string */
struct rspamd_external_libs_ctx *libs_ctx; /**< context for external libraries */
struct rspamd_monitored_ctx *monitored_ctx; /**< context for monitored resources */
- struct rspamd_redis_pool *redis_pool; /**< redis connectiosn pool */
+ struct rspamd_redis_pool *redis_pool; /**< redis connection pool */
struct rspamd_re_cache *re_cache; /**< static regexp cache */
More information about the Commits
mailing list