增加MESA_handle_logger

This commit is contained in:
luwenpeng
2023-02-20 11:16:34 +08:00
parent 6eaad28f9c
commit 82ac815b68
10 changed files with 108 additions and 95 deletions

View File

@@ -1,11 +1,21 @@
#include <errno.h>
#include <unistd.h>
#include <signal.h>
#include <pthread.h>
#include "sce.h"
#include "log.h"
#include "utils.h"
static void sig_handler(int signo)
{
if (signo == SIGHUP)
{
LOG_INFO("%s: recv SIGHUP, reload zlog.conf", LOG_TAG_SCE);
LOG_RELOAD();
}
}
static void *worker_thread_cycle(void *arg)
{
struct thread_ctx *thread_ctx = (struct thread_ctx *)arg;
@@ -43,9 +53,22 @@ int main(int argc, char **argv)
{
const char *profile = "./conf/sce.conf";
if (LOG_INIT("./conf/zlog.conf") == -1)
{
return -1;
}
if (signal(SIGHUP, sig_handler) == SIG_ERR)
{
LOG_ERROR("%s: unable to register SIGHUP signal handler, error %d: %s", LOG_TAG_SCE, errno, strerror(errno));
LOG_CLOSE();
return -1;
}
struct sce_ctx *ctx = sce_ctx_create(profile);
if (ctx == NULL)
{
LOG_CLOSE();
return -1;
}
@@ -85,5 +108,7 @@ error_out:
}
sce_ctx_destory(ctx);
LOG_CLOSE();
return 0;
}