]> git.ipfire.org Git - collecty.git/commitdiff
main: Initialize the daemon
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 27 Sep 2025 12:03:03 +0000 (12:03 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 27 Sep 2025 12:03:03 +0000 (12:03 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/daemon/main.c

index 92dff8e9308d84f7b51a84472048c6e2639a0028..dbcc3fb16262afce14a48b1336f11b897007fa78 100644 (file)
 #include <argp.h>
 #include <stddef.h>
 #include <stdlib.h>
+#include <string.h>
 #include <syslog.h>
 
 #include "ctx.h"
+#include "daemon.h"
 #include "logging.h"
 
 const char* argp_program_version = PACKAGE_VERSION;
@@ -59,6 +61,7 @@ static error_t parse(int key, char* arg, struct argp_state* state) {
 }
 
 int main(int argc, char* argv[]) {
+       collecty_daemon* daemon = NULL;
        collecty_ctx* ctx = NULL;
        struct argp parser = {
                .options = options,
@@ -78,9 +81,16 @@ int main(int argc, char* argv[]) {
        if (r)
                goto ERROR;
 
-       INFO(ctx, "Daemon initialized\n");
+       // Create a daemon
+       r = collecty_daemon_create(&daemon, ctx);
+       if (r < 0) {
+               ERROR(ctx, "Failed to initialize the daemon: %s\n", strerror(-r));
+               goto ERROR;
+       }
 
 ERROR:
+       if (daemon)
+               collecty_daemon_unref(daemon);
        if (ctx)
                collecty_ctx_unref(ctx);