#include "bus.h"
#include "ctx.h"
#include "daemon.h"
+#include "graphs.h"
#include "graph-bus.h"
#include "module.h"
#include "modules.h"
// Queue
collecty_queue* queue;
+
+ // Graphs
+ collecty_graphs* graphs;
};
static int collecty_daemon_init(sd_event_source* source, void* data) {
collecty_daemon* self = data;
+ int r;
DEBUG(self->ctx, "Initializing daemon...\n");
// Initialize all modules
- return collecty_modules_init(self->ctx, self);
+ r = collecty_modules_init(self->ctx, self);
+ if (r < 0)
+ return r;
+
+ // Initialize all graphs
+ r = collecty_graphs_create(&self->graphs, self->ctx, self);
+ if (r < 0)
+ return r;
+
+ return 0;
}
static int collecty_daemon_exit(sd_event_source* source, void* data) {
DEBUG(self->ctx, "Cleaning up daemon...\n");
+ // Free all graphs
+ if (self->graphs) {
+ collecty_graphs_unref(self->graphs);
+ self->graphs = NULL;
+ }
+
return 0;
}
sd_event_source_unref(self->events.init);
if (self->events.exit)
sd_event_source_unref(self->events.exit);
+ if (self->graphs)
+ collecty_graphs_unref(self->graphs);
if (self->queue)
collecty_queue_unref(self->queue);
if (self->ctx)