commit d48387a5fa2549e598a873891eac82a5c9da79f6
parent 76e47c4007d8a656248a608001bfde848cafd40b
Author: Remy Noulin <loader2x@gmail.com>
Date: Fri, 7 Jul 2023 14:41:09 +0200
add daemon functionality
heartbeat.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
Diffstat:
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/heartbeat.c b/heartbeat.c
@@ -2,9 +2,11 @@
/* or direct path to sheepy: #! /usr/local/bin/sheepy */
/* Libsheepy documentation: https://spartatek.se/libsheepy/ */
+#include <unistd.h> // for daemon
#include "libsheepyObject.h"
#include "shpPackages/short/short.h"
+
/*
Commands:
no command: load config.yml
@@ -61,6 +63,7 @@ int main(int ARGC, char** ARGV) {
disableLibsheepyErrorLogs;
if (argc == 1) {
+ runProbes:;
// no arguments
cleanCharP(p) = expandHome(agentCfgFile);
if (!isPath(p)) {
@@ -76,8 +79,13 @@ int main(int ARGC, char** ARGV) {
ret 1;
}
elif (eqG(argv[1], "daemon")) {
- TODO("daemon");
- ret 1;
+ cleanCharP(h) = expandHome("~/" home "/heartbeat.log");
+ setLogFile(h);
+ setLogStdout(no);
+ #define KEEP_CWD 1
+ #define STDIO_DEV_NULL 0
+ daemon(KEEP_CWD, STDIO_DEV_NULL);
+ goto runProbes;
}
elif (eqG(argv[1], "monitor")) {
TODO("monitor");