v0.1.30 - add public GET /health JSON endpoint with status version and uptime
This commit is contained in:
Binary file not shown.
BIN
build/main.o
BIN
build/main.o
Binary file not shown.
@@ -10,8 +10,8 @@
|
||||
// Version information (auto-updated by build system)
|
||||
#define VERSION_MAJOR 0
|
||||
#define VERSION_MINOR 1
|
||||
#define VERSION_PATCH 29
|
||||
#define VERSION "v0.1.29"
|
||||
#define VERSION_PATCH 30
|
||||
#define VERSION "v0.1.30"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
19
src/main.c
19
src/main.c
@@ -27,6 +27,7 @@
|
||||
|
||||
// Shutdown flag set by signal handler - volatile sig_atomic_t is async-signal-safe
|
||||
static volatile sig_atomic_t g_shutdown_requested = 0;
|
||||
static time_t g_server_start_time = 0;
|
||||
|
||||
static void shutdown_handler(int signum) {
|
||||
(void)signum;
|
||||
@@ -2144,6 +2145,7 @@ int main(int argc, char *argv[]) {
|
||||
// Initialize application logging
|
||||
app_log(LOG_INFO, "=== Ginxsom FastCGI Application Starting ===");
|
||||
app_log(LOG_INFO, "Process ID: %d", getpid());
|
||||
g_server_start_time = time(NULL);
|
||||
|
||||
// Parse command line arguments
|
||||
int use_test_keys = 0;
|
||||
@@ -3061,6 +3063,23 @@ if (!config_loaded /* && !initialize_server_config() */) {
|
||||
strcmp(request_uri, "/auth") == 0) {
|
||||
// Handle GET /auth requests using the existing handler
|
||||
handle_auth_challenge_request();
|
||||
} else if (strcmp(request_method, "GET") == 0 &&
|
||||
strcmp(request_uri, "/health") == 0) {
|
||||
// Handle GET /health requests - simple public health response
|
||||
time_t now = time(NULL);
|
||||
long uptime_seconds = 0;
|
||||
if (g_server_start_time > 0 && now >= g_server_start_time) {
|
||||
uptime_seconds = (long)(now - g_server_start_time);
|
||||
}
|
||||
|
||||
printf("Status: 200 OK\r\n");
|
||||
printf("Content-Type: application/json\r\n\r\n");
|
||||
printf("{\n");
|
||||
printf(" \"status\": \"ok\",\n");
|
||||
printf(" \"version\": \"%s\",\n", VERSION);
|
||||
printf(" \"uptime\": %ld\n", uptime_seconds);
|
||||
printf("}\n");
|
||||
log_request("GET", "/health", "public", 200);
|
||||
} else if (strcmp(request_method, "DELETE") == 0) {
|
||||
// Handle DELETE /<sha256> requests with pre-validated auth
|
||||
const char *sha256 = extract_sha256_from_uri(request_uri);
|
||||
|
||||
Reference in New Issue
Block a user