feat: add logging system, orchestrator, and documentation

This commit is contained in:
Loic Coenen
2026-05-19 08:26:36 +00:00
parent f776b8a361
commit e79c2ac116
27 changed files with 612 additions and 13 deletions

51
orchestrator.c Normal file
View File

@@ -0,0 +1,51 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <sys/wait.h>
#include <string.h>
static pid_t engine_pid = 0;
static pid_t client_pid = 0;
static void cleanup(int sig) {
(void)sig;
if (engine_pid > 0) kill(engine_pid, SIGTERM);
if (client_pid > 0) kill(client_pid, SIGTERM);
while (wait(NULL) > 0);
_exit(0);
}
int main(int argc, char *argv[]) {
signal(SIGINT, cleanup);
signal(SIGTERM, cleanup);
engine_pid = fork();
if (engine_pid == 0) {
execl("./engine/looper", "looper", NULL);
perror("execl engine");
_exit(1);
}
client_pid = fork();
if (client_pid == 0) {
if (argc > 2 && strcmp(argv[1], "-s") == 0) {
execl("./client/looper-client", "looper-client", "-s", argv[2], NULL);
} else {
execl("./client/looper-client", "looper-client", NULL);
}
perror("execl client");
_exit(1);
}
int status;
pid_t exited = wait(&status);
if (exited == engine_pid) {
kill(client_pid, SIGTERM);
wait(NULL);
} else if (exited == client_pid) {
kill(engine_pid, SIGTERM);
wait(NULL);
}
return 0;
}