-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
58 lines (47 loc) · 989 Bytes
/
Copy pathmain.cpp
File metadata and controls
58 lines (47 loc) · 989 Bytes
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
#include "svc.h"
#include "base/utils.h"
#include <string.h>
#include <iostream>
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)
{
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 << "piperserver "<< 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;
}