http.c improvements
This commit is contained in:
22
src/main.c
22
src/main.c
@@ -7,31 +7,29 @@
|
||||
#include "utils/colors.h"
|
||||
#include "utils/config.h"
|
||||
|
||||
void cws_signal_handler(int signo) { cws_server_run = false; }
|
||||
void cws_signal_handler(int signo) { cws_server_run = 0; }
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int ret;
|
||||
|
||||
struct sigaction act = {.sa_handler = cws_signal_handler};
|
||||
ret = sigaction(SIGINT, &act, NULL);
|
||||
if (ret) {
|
||||
int main(void) {
|
||||
struct sigaction act = {.sa_handler = cws_signal_handler, .sa_flags = 0, .sa_mask = {{0}}};
|
||||
if (sigaction(SIGINT, &act, NULL)) {
|
||||
CWS_LOG_ERROR("sigaction(): %s", strerror(errno));
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
cws_config *config = cws_config_init();
|
||||
if (config == NULL) {
|
||||
if (!config) {
|
||||
CWS_LOG_ERROR("Unable to read config file");
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
CWS_LOG_INFO("Running cws on http://%s:%s...", config->hostname, config->port);
|
||||
ret = cws_server_start(config);
|
||||
int ret = cws_server_start(config);
|
||||
if (ret < 0) {
|
||||
CWS_LOG_ERROR("Unable to start web server");
|
||||
}
|
||||
|
||||
CWS_LOG_INFO("Shutting down cws...");
|
||||
cws_config_free(config);
|
||||
|
||||
return 0;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user