forked from johanvon/mariotcp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mario.c
54 lines (44 loc) · 1.06 KB
/
mario.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
* mario.c
*
* 名称:Mario
*
* Date: 2013-3-1
* Author: feng jianhua (johan fong)
* Mail: [email protected]
*
* 修改记录:
*/
#include <stdio.h>
#include <stdlib.h>
#include "mario/mario.h"
#include "function.h"
#include "config.h"
#include "protocol.h"
#include "collect.h"
#include <pthread.h>
int main(void) {
run_daemon();
if (init_conf() < 0)
return -1;
if (init_collect() < 0)
return -1;
SERVER *server = init_server(conf->port, conf->workernum, conf->connnum, conf->timeout,
conf->timeout);
if (server == NULL)
return -1;
regist_akg_func(CMD_FUNCTION_LOGIN, login);
regist_disconnected_func(logout);
if (start_log_thread() != 0) {
fprintf(stderr, "[error] start_log_thread, errno: %d %m\n", errno);
return -1;
}
if (start_collect_thread() != 0) {
fprintf(stderr, "[error] start_collect_thread, errno: %d %m\n", errno);
return -1;
}
//协议头HEAD的结构请见mario_akg.h,包含一个uint32的token,可用过此函数来注册;如果不注册,则默认为DEFAULT_STX
regist_stx(0x8eb69af7);
start_server((void*) server);
return EXIT_SUCCESS;
}