This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
stellar-stellar/src/core/main.cpp

58 lines
1.3 KiB
C++
Raw Normal View History

#include <stdio.h>
#include <stddef.h>
#include <signal.h>
#include "stellar/stellar.h"
#include "stellar_core.h"
struct stellar *st = NULL;
static void signal_handler(int signo)
{
if (signo == SIGINT)
{
printf("SIGINT received, notify threads to exit\n");
stellar_loopbreak(st);
}
if (signo == SIGQUIT)
{
printf("SIGQUIT received, notify threads to exit\n");
stellar_loopbreak(st);
}
if (signo == SIGTERM)
{
printf("SIGTERM received, notify threads to exit\n");
stellar_loopbreak(st);
}
if (signo == SIGHUP)
{
printf("SIGHUP received, reload log level\n");
stellar_reload_log_level(st);
}
}
int main(int argc __attribute__((__unused__)), char **argv __attribute__((__unused__)))
{
const char *stellar_cfg_file = "./conf/stellar.toml";
const char *plugin_cfg_file = "./plugin/spec.toml";
const char *log_cfg_file = "./conf/log.toml";
signal(SIGINT, signal_handler);
signal(SIGQUIT, signal_handler);
signal(SIGTERM, signal_handler);
signal(SIGHUP, signal_handler);
st = stellar_new(stellar_cfg_file, plugin_cfg_file, log_cfg_file);
if (st == NULL)
{
return 0;
}
stellar_run(st);
stellar_free(st);
return 0;
}