2018-05-27 18:03:10 +00:00
|
|
|
#include <llarp.h>
|
2018-07-11 11:04:15 +00:00
|
|
|
#include <llarp/logger.h>
|
2018-07-13 13:36:51 +00:00
|
|
|
#include <signal.h>
|
2018-07-20 04:50:28 +00:00
|
|
|
#include <string>
|
2018-05-20 16:15:16 +00:00
|
|
|
|
2018-07-30 04:38:14 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
#define wmin(x, y) (((x) < (y)) ? (x) : (y))
|
|
|
|
#define MIN wmin
|
|
|
|
#endif
|
|
|
|
|
2018-05-27 18:03:10 +00:00
|
|
|
struct llarp_main *ctx = 0;
|
2018-04-30 16:14:20 +00:00
|
|
|
|
2018-05-22 15:54:19 +00:00
|
|
|
void
|
|
|
|
handle_signal(int sig)
|
2018-05-18 17:50:21 +00:00
|
|
|
{
|
2018-05-27 17:44:01 +00:00
|
|
|
if(ctx)
|
2018-05-27 18:03:10 +00:00
|
|
|
llarp_main_signal(ctx, sig);
|
2018-05-18 17:50:21 +00:00
|
|
|
}
|
|
|
|
|
2018-05-22 15:54:19 +00:00
|
|
|
int
|
|
|
|
main(int argc, char *argv[])
|
|
|
|
{
|
2018-07-20 04:50:28 +00:00
|
|
|
bool multiThreaded = true;
|
|
|
|
const char *singleThreadVar = getenv("LLARP_SHADOW");
|
|
|
|
if(singleThreadVar && std::string(singleThreadVar) == "1")
|
|
|
|
{
|
|
|
|
multiThreaded = false;
|
|
|
|
}
|
2018-07-26 10:52:23 +00:00
|
|
|
const char *conffname = handleBaseCmdLineArgs(argc, argv);
|
2018-07-27 00:21:57 +00:00
|
|
|
|
|
|
|
if(!llarp_ensure_config(conffname))
|
|
|
|
return 1;
|
2018-07-13 13:36:51 +00:00
|
|
|
|
2018-07-20 04:50:28 +00:00
|
|
|
ctx = llarp_main_init(conffname, multiThreaded);
|
2018-05-27 19:13:25 +00:00
|
|
|
int code = 1;
|
|
|
|
if(ctx)
|
2018-05-27 18:03:10 +00:00
|
|
|
{
|
|
|
|
signal(SIGINT, handle_signal);
|
2018-05-27 19:13:25 +00:00
|
|
|
code = llarp_main_run(ctx);
|
2018-07-20 04:50:28 +00:00
|
|
|
llarp_main_free(ctx);
|
2018-05-27 18:03:10 +00:00
|
|
|
}
|
2018-08-12 17:22:29 +00:00
|
|
|
exit(code);
|
2018-05-27 19:13:25 +00:00
|
|
|
return code;
|
2017-09-28 17:02:05 +00:00
|
|
|
}
|