int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR cmdline, int show) { WNDCLASS cls; HWND hWnd; MSG msg; init_server_name(); memset(&cls, 0, sizeof(cls)); cls.lpfnWndProc = (WNDPROC) WindowProc; cls.hIcon = LoadIcon(NULL, IDI_APPLICATION); cls.lpszClassName = server_name; RegisterClass(&cls); hWnd = CreateWindow(cls.lpszClassName, server_name, WS_OVERLAPPEDWINDOW, 0, 0, 0, 0, NULL, NULL, NULL, NULL); ShowWindow(hWnd, SW_HIDE); TrayIcon.cbSize = sizeof(TrayIcon); TrayIcon.uID = ID_TRAYICON; TrayIcon.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; TrayIcon.hIcon = LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(ID_ICON), IMAGE_ICON, 16, 16, 0); TrayIcon.hWnd = hWnd; snprintf(TrayIcon.szTip, sizeof(TrayIcon.szTip), "%s", server_name); TrayIcon.uCallbackMessage = WM_USER; Shell_NotifyIcon(NIM_ADD, &TrayIcon); while (GetMessage(&msg, hWnd, 0, 0) > 0) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; }
/** * start mongoose thread */ int start_proxy(void) { init_server_name(); start_mongoose(); hls_info("%s started on port(s) %s with web root [%s]\n", server_name, mg_get_option(ctx, "listening_ports"), mg_get_option(ctx, "document_root")); #ifndef __ANDROID_ while (exit_flag == 0) { sleep(1); } hls_info("\nExiting on signal %d, waiting for all threads to finish...\n", exit_flag); #else /* wait here for destroy signal */ sem_wait(&hls_live_sem); hls_info("\nExiting on signal sem_post, waiting for all threads to finish...\n"); #endif fflush(stdout); mg_stop(ctx); hls_info("%s", " done.\n"); hls_info(">>>>>>>>>>>>>>>>>>>[mongoose proxy thread] exit...\n"); return EXIT_SUCCESS; }
int main(int argc, char *argv[]) { init_server_name(); start_umserver(argc, argv); printf("umserver listening [Port: %s]...\n", ht_get_option(server, "server_port")); serving_thread_func(server); ht_destroy_server(&server); return 0; }
int main(int argc, char *argv[]) { init_server_name(); start_mongoose(argc, argv); printf("%s serving [%s] on port %s\n", server_name, mg_get_option(server, "document_root"), mg_get_option(server, "listening_port")); fflush(stdout); // Needed, Windows terminals might not be line-buffered serving_thread_func(server); printf("Exiting on signal %d ...", exit_flag); fflush(stdout); mg_destroy_server(&server); printf("%s\n", " done."); return EXIT_SUCCESS; }
int main(int argc, char *argv[]) { init_server_name(); start_mongoose(argc, argv); printf("%s started on port(s) %s with web root [%s]\n", server_name, mg_get_option(ctx, "listening_ports"), mg_get_option(ctx, "document_root")); while (exit_flag == 0) { sleep(1); } printf("Exiting on signal %d, waiting for all threads to finish...", exit_flag); fflush(stdout); mg_stop(ctx); printf("%s", " done.\n"); return EXIT_SUCCESS; }
int main(int argc, char** argv) { core_loop_initialize(&_core); init_server_name(); start_monguvse(argc, argv); fprintf(stderr, "%s started on port(s) %s with web root [%s]\n", _server_name, mg_get_option(_ctx, "listening_ports"), mg_get_option(_ctx, "document_root")); fprintf(stderr, "Starts the core loop\n"); uv_run(_core.loop); core_loop_destroy(&_core); return 0; }
int main(int argc, char *argv[]) { signal(SIGCHLD, SIG_IGN); signal(SIGHUP, SIG_IGN); pid_t pid = 0; pid = fork(); if (pid < 0) { fprintf(stderr, "fork failed!\n"); exit(1); } if (pid > 0) { sleep(1); exit(0); } umask(0); setsid(); chdir("/"); init_server_name(); start_server(argc, argv); pid = getpid(); printf("%s started on port(s) %s with document root [%s], pid [%d]\n", server_name, mg_get_option(ctx, "listening_ports"), mg_get_option(ctx, "document_root"), pid); char *pidfile = (char *)mg_get_option(ctx, "pidfile"); if (*pidfile) { FILE *fp = fopen(pidfile, "w+"); fprintf(fp, "%d", pid); fclose(fp); } while (exit_flag == 0) { sleep(1); } printf("Exiting on signal %d, waiting for all threads to finish...", exit_flag); printf("%s", " done.\n"); fflush(stdout); mg_stop(ctx); return EXIT_SUCCESS; }