forked from github/brubeck
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbrubeck.c
46 lines (42 loc) · 1.19 KB
/
brubeck.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
#include "brubeck.h"
#include "getopt.h"
int main(int argc, char *argv[]) {
static struct option longopts[] = {
{"log", required_argument, NULL, 'l'},
{"config", required_argument, NULL, 'c'},
{"version", no_argument, NULL, 'v'},
{"no-setproctitle", no_argument, NULL, 'n'},
{NULL, 0, NULL, 0}};
struct brubeck_server server;
memset(&server, 0x0, sizeof(struct brubeck_server));
server.set_proctitle = true;
const char *config_file = "config.default.json";
const char *log_file = NULL;
int opt;
while ((opt = getopt_long(argc, argv, ":l:c:vn", longopts, NULL)) != -1) {
switch (opt) {
case 'l':
log_file = optarg;
break;
case 'c':
config_file = optarg;
break;
case 'v':
puts("brubeck " GIT_SHA);
return 0;
case 'n':
server.set_proctitle = false;
break;
default:
printf("Usage: %s [--log LOG_FILE] [--config CONFIG_FILE] [--version] "
"[--no-setproctitle] \n",
argv[0]);
return 1;
}
}
if (server.set_proctitle)
initproctitle(argc, argv);
gh_log_open(log_file);
brubeck_server_init(&server, config_file);
return brubeck_server_run(&server);
}