2023-05-26 15:48:20 +01:00
|
|
|
// Copyright (c) 2020-2023 Cesanta Software Limited
|
2020-12-05 11:26:32 +00:00
|
|
|
// All rights reserved
|
|
|
|
|
2023-05-26 14:43:36 -03:00
|
|
|
#include "mongoose.h"
|
2023-05-26 15:48:20 +01:00
|
|
|
#include "net.h"
|
2023-02-22 16:38:21 -03:00
|
|
|
|
2023-05-26 15:48:20 +01:00
|
|
|
static int s_sig_num;
|
|
|
|
static void signal_handler(int sig_num) {
|
|
|
|
signal(sig_num, signal_handler);
|
|
|
|
s_sig_num = sig_num;
|
|
|
|
}
|
2020-12-05 11:26:32 +00:00
|
|
|
|
|
|
|
int main(void) {
|
|
|
|
struct mg_mgr mgr;
|
2023-05-26 15:48:20 +01:00
|
|
|
|
|
|
|
signal(SIGPIPE, SIG_IGN);
|
|
|
|
signal(SIGINT, signal_handler);
|
|
|
|
signal(SIGTERM, signal_handler);
|
|
|
|
|
2022-08-01 11:19:32 +01:00
|
|
|
mg_log_set(MG_LL_DEBUG); // Set debug log level
|
2020-12-05 11:26:32 +00:00
|
|
|
mg_mgr_init(&mgr);
|
2023-05-26 15:48:20 +01:00
|
|
|
|
|
|
|
web_init(&mgr);
|
|
|
|
while (s_sig_num == 0) {
|
|
|
|
mg_mgr_poll(&mgr, 50);
|
|
|
|
}
|
|
|
|
|
2022-05-15 14:40:58 +01:00
|
|
|
mg_mgr_free(&mgr);
|
2023-05-26 15:48:20 +01:00
|
|
|
MG_INFO(("Exiting on signal %d", s_sig_num));
|
|
|
|
|
2020-12-05 11:26:32 +00:00
|
|
|
return 0;
|
|
|
|
}
|