add log and remove notes
This commit is contained in:
17
src/main.c
17
src/main.c
@@ -1,36 +1,31 @@
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "server/server.h"
|
||||
#include "utils/colors.h"
|
||||
#include "utils/config.h"
|
||||
|
||||
void cws_signal_handler(int signo) {
|
||||
fprintf(stdout, BLUE "[server] Cleaning up resources...\n" RESET);
|
||||
cws_server_run = false;
|
||||
}
|
||||
void cws_signal_handler(int signo) { cws_server_run = false; }
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int ret;
|
||||
|
||||
cws_config *config = cws_config_init();
|
||||
if (config == NULL) {
|
||||
fprintf(stderr, RED BOLD "[server] Unable to read config file\n" RESET);
|
||||
CWS_LOG_ERROR("[server] Unable to read config file");
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct sigaction act = {
|
||||
.sa_handler = cws_signal_handler
|
||||
};
|
||||
struct sigaction act = {.sa_handler = cws_signal_handler};
|
||||
ret = sigaction(SIGINT, &act, NULL);
|
||||
|
||||
fprintf(stdout, BOLD GREEN "[server] Running cws on http://%s:%s...\n" RESET, config->host, config->port);
|
||||
CWS_LOG_INFO("[server] Running cws on http://%s:%s...", config->host, config->port);
|
||||
|
||||
ret = cws_server_start(config->host, config->port);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, BOLD RED "[server] Unable to start web server\n" RESET);
|
||||
CWS_LOG_ERROR("[server] Unable to start web server");
|
||||
}
|
||||
|
||||
cws_config_free(config);
|
||||
|
||||
Reference in New Issue
Block a user