summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index 901ce74..af86375 100644
--- a/src/main.c
+++ b/src/main.c
@@ -4,6 +4,7 @@
#include "client.h"
#include "log.h"
#include "log_tail.h"
+#include "filter.h"
#include <stdio.h>
#include <stdlib.h>
@@ -60,9 +61,12 @@ static void handle_signal(void) {
case SIGHUP:
log_info("SIGHUP received — reloading units");
log_tail_cleanup();
+ filter_stop_all();
/* Reload unit descriptors. Existing runtime state is preserved. */
g.unit_count = 0;
unit_load_all();
+ for (int i = 0; i < g.unit_count; i++)
+ filter_start(&g.units[i]);
log_tail_init();
break;
}
@@ -96,7 +100,10 @@ static void handle_process_output(int fd) {
}
buf[n] = '\0';
- ring_push(u->output, buf, n);
+ int nf = (int)n;
+ filter_apply(u, buf, sizeof(buf), &nf);
+ if (nf <= 0) return;
+ ring_push(u->output, buf, nf);
client_broadcast_output(u->name, buf, 0);
}
@@ -214,6 +221,9 @@ int main(int argc, char *argv[]) {
return 1;
}
+ for (int i = 0; i < g.unit_count; i++)
+ filter_start(&g.units[i]);
+
log_tail_init();
/* Set up listening socket */
@@ -235,6 +245,7 @@ int main(int argc, char *argv[]) {
log_info("Shutting down");
log_tail_cleanup();
+ filter_stop_all();
daemon_cleanup();
log_close();
return 0;