|
|
@@ -1,7 +1,8 @@ |
|
|
|
#include "IZ_app.h" |
|
|
|
|
|
|
|
void IZ_AppHandleSignal(i32 _signal) { |
|
|
|
IZ_WSServerCancelService(&global_app.server); |
|
|
|
global_app->server.ws.interrupted = true; |
|
|
|
IZ_WSServerCancelService(&global_app->server); |
|
|
|
} |
|
|
|
|
|
|
|
// TODO move to each subsystem |
|
|
@@ -21,6 +22,8 @@ void IZ_AppLoadConfig(IZ_App *app, u8 argc, const char **argv) { |
|
|
|
|
|
|
|
IZ_ProcedureResult IZ_AppInitialize(IZ_App *app, u8 argc, const char **argv) { |
|
|
|
signal(SIGINT, IZ_AppHandleSignal); |
|
|
|
signal(9, IZ_AppHandleSignal); |
|
|
|
signal(SIGTERM, IZ_AppHandleSignal); |
|
|
|
|
|
|
|
IZ_AppLoadConfig(app, argc, argv); |
|
|
|
IZ_LogInterceptWSMessages(app->config.log_level); |
|
|
@@ -33,6 +36,7 @@ IZ_ProcedureResult IZ_AppInitialize(IZ_App *app, u8 argc, const char **argv) { |
|
|
|
return -1; |
|
|
|
} |
|
|
|
|
|
|
|
global_app = app; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
@@ -42,22 +46,18 @@ IZ_ProcedureResult IZ_AppRun(IZ_App *app, u8 argc, const char **argv) { |
|
|
|
} |
|
|
|
|
|
|
|
i32 result = 0; |
|
|
|
while (!app->server.ws.interrupted) { |
|
|
|
printf("A\n"); |
|
|
|
while (true) { |
|
|
|
if (IZ_WSServerHandle(&app->server)) { |
|
|
|
printf("B\n"); |
|
|
|
result = -1; |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
if (app->server.ws.interrupted) { |
|
|
|
printf("C\n"); |
|
|
|
break; |
|
|
|
} |
|
|
|
printf("D\n"); |
|
|
|
} |
|
|
|
|
|
|
|
IZ_WSServerTeardown(&app->server); |
|
|
|
printf("%u\n", result); |
|
|
|
lwsl_user("Server closed. Bye!\n"); |
|
|
|
return result; |
|
|
|
} |