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