Skip to content

Commit

Permalink
update ltp_server for one thread, Ctrl-C exit. Delete Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
carfly committed Jul 22, 2013
1 parent 40b1b6c commit 9d8997b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 43 deletions.
40 changes: 0 additions & 40 deletions Makefile

This file was deleted.

17 changes: 14 additions & 3 deletions src/server/ltp_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <sys/wait.h>
#include <unistd.h> /* For pause() */
#include <stdlib.h>
#include <signal.h>

#include <iostream>

Expand All @@ -23,13 +24,21 @@ using namespace std;
static XML4NLP xml4nlp;
static LTP ltp(xml4nlp);

static int exit_flag;

static int Service(struct mg_connection *conn);

static void signal_handler(int sig_num) {
exit_flag = sig_num;
}

int main(int argc, char *argv[])
{
signal(SIGTERM, signal_handler);
signal(SIGINT, signal_handler);
struct mg_context *ctx;
const char *options[] = {"listening_ports", LISTENING_PORT, NULL};
const char *options[] = {"listening_ports", LISTENING_PORT,
"num_threads", "1", NULL};
struct mg_callbacks callbacks;

memset(&callbacks, 0, sizeof(callbacks));
Expand All @@ -40,8 +49,10 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}

getchar();

// getchar();
while (exit_flag == 0) {
sleep(100000);
}
mg_stop(ctx);

return 0;
Expand Down

0 comments on commit 9d8997b

Please sign in to comment.