906948
906948
More verbose startup logging for mod_systemd.
906948
906948
--- httpd-2.4.43/modules/arch/unix/mod_systemd.c.mod_systemd
906948
+++ httpd-2.4.43/modules/arch/unix/mod_systemd.c
906948
@@ -29,11 +29,14 @@
906948
 #include "mpm_common.h"
906948
 
906948
 #include "systemd/sd-daemon.h"
906948
+#include "systemd/sd-journal.h"
906948
 
906948
 #if APR_HAVE_UNISTD_H
906948
 #include <unistd.h>
906948
 #endif
906948
 
906948
+static char describe_listeners[30];
906948
+
906948
 static int systemd_pre_config(apr_pool_t *pconf, apr_pool_t *plog,
906948
                               apr_pool_t *ptemp)
906948
 {
906948
@@ -44,6 +47,20 @@
906948
     return OK;
906948
 }
906948
 
906948
+static char *dump_listener(ap_listen_rec *lr, apr_pool_t *p)
906948
+{
906948
+    apr_sockaddr_t *sa = lr->bind_addr;
906948
+    char addr[128];
906948
+
906948
+    if (apr_sockaddr_is_wildcard(sa)) {
906948
+        return apr_pstrcat(p, "port ", apr_itoa(p, sa->port), NULL);
906948
+    }
906948
+
906948
+    apr_sockaddr_ip_getbuf(addr, sizeof addr, sa);
906948
+
906948
+    return apr_psprintf(p, "%s port %u", addr, sa->port);
906948
+}
906948
+
906948
 /* Report the service is ready in post_config, which could be during
906948
  * startup or after a reload.  The server could still hit a fatal
906948
  * startup error after this point during ap_run_mpm(), so this is
906948
@@ -51,19 +68,51 @@
906948
  * the TCP ports so new connections will not be rejected.  There will
906948
  * always be a possible async failure event simultaneous to the
906948
  * service reporting "ready", so this should be good enough. */
906948
-static int systemd_post_config(apr_pool_t *p, apr_pool_t *plog,
906948
+static int systemd_post_config(apr_pool_t *pconf, apr_pool_t *plog,
906948
                                apr_pool_t *ptemp, server_rec *main_server)
906948
 {
906948
+    ap_listen_rec *lr;
906948
+    apr_size_t plen = sizeof describe_listeners;
906948
+    char *p = describe_listeners;
906948
+
906948
+    if (ap_state_query(AP_SQ_MAIN_STATE) == AP_SQ_MS_CREATE_PRE_CONFIG)
906948
+        return OK;
906948
+
906948
+    for (lr = ap_listeners; lr; lr = lr->next) {
906948
+        char *s = dump_listener(lr, ptemp);
906948
+
906948
+        if (strlen(s) + 3 < plen) {
906948
+            char *newp = apr_cpystrn(p, s, plen);
906948
+            if (lr->next)
906948
+                newp = apr_cpystrn(newp, ", ", 3);
906948
+            plen -= newp - p;
906948
+            p = newp;
906948
+        }
906948
+        else {
906948
+            if (plen < 4) {
906948
+                p = describe_listeners + sizeof describe_listeners - 4;
906948
+                plen = 4;
906948
+            }
906948
+            apr_cpystrn(p, "...", plen);
906948
+            break;
906948
+        }
906948
+    }
906948
+
906948
     sd_notify(0, "READY=1\n"
906948
               "STATUS=Configuration loaded.\n");
906948
+
906948
+    sd_journal_print(LOG_INFO, "Server configured, listening on: %s",
906948
+                     describe_listeners);
906948
+
906948
     return OK;
906948
 }
906948
 
906948
 static int systemd_pre_mpm(apr_pool_t *p, ap_scoreboard_e sb_type)
906948
 {
906948
     sd_notifyf(0, "READY=1\n"
906948
-               "STATUS=Processing requests...\n"
906948
-               "MAINPID=%" APR_PID_T_FMT, getpid());
906948
+               "STATUS=Started, listening on: %s\n"
906948
+               "MAINPID=%" APR_PID_T_FMT,
906948
+               describe_listeners, getpid());
906948
 
906948
     return OK;
906948
 }