-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
74 lines (62 loc) · 1.28 KB
/
main.cpp
File metadata and controls
74 lines (62 loc) · 1.28 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include "svc.h"
#include "base/utils.h"
#include <string.h>
#include <iostream>
//#include "common_utils.h"
using namespace std;
using namespace base;
GHANDLE * _p = NULL;
void sigusr1_handle( int iSigVal )
{
svc_reload(_p);
signal(SIGUSR1, sigusr1_handle);
}
void sigusr2_handle( int iSigVal )
{
svc_quit(_p);
signal(SIGUSR2, sigusr2_handle);
}
int main(int argc, char **argv)
{
/*int nMatch = 0;
for (unsigned int i = 0; i < 40;++i)
{
if (common_utils::match_rate(50))
{
cout <<"match"<<endl;
++nMatch;
continue;
}
cout <<"not match"<<endl;
}
cout <<"match:"<<nMatch<<endl;
return 0;
*/
char version[128];
unsigned versionsize = sizeof(version);
char errormsg[4096];
unsigned msgsize = sizeof(errormsg);
svc_version(version, versionsize);
if(argc<2 || strcasecmp(argv[1],"HELP")==0)
{
cout << "Usage: " << argv[0] << " configfile" << endl;
exit(1);
}
if(argc<3 || strcasecmp(argv[2],"debug")!=0)
{
Daemon();
}
cout << "sproxy "<< version << endl;
signal(SIGUSR1, sigusr1_handle);
signal(SIGUSR2, sigusr2_handle);
_p = svc_create(argv[1], errormsg, msgsize);
if(_p == NULL)
{
cerr << errormsg << endl;
exit(-1);
}
svc_run(_p);
svc_destory(_p);
_p = NULL;
return 0;
}