mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-10-29 11:05:43 +00:00
48 lines
884 B
C++
48 lines
884 B
C++
#include <llarp.h>
|
|
#include <llarp/logger.h>
|
|
#include <signal.h>
|
|
#include <string>
|
|
|
|
#ifdef _WIN32
|
|
#define wmin(x, y) (((x) < (y)) ? (x) : (y))
|
|
#define MIN wmin
|
|
#endif
|
|
|
|
struct llarp_main *ctx = 0;
|
|
|
|
void
|
|
handle_signal(int sig)
|
|
{
|
|
if(ctx)
|
|
llarp_main_signal(ctx, sig);
|
|
}
|
|
|
|
int
|
|
main(int argc, char *argv[])
|
|
{
|
|
bool multiThreaded = true;
|
|
const char *singleThreadVar = getenv("LLARP_SHADOW");
|
|
if(singleThreadVar && std::string(singleThreadVar) == "1")
|
|
{
|
|
multiThreaded = false;
|
|
}
|
|
const char *conffname = handleBaseCmdLineArgs(argc, argv);
|
|
|
|
if(!llarp_ensure_config(conffname))
|
|
return 1;
|
|
|
|
ctx = llarp_main_init(conffname, multiThreaded);
|
|
int code = 1;
|
|
if(ctx)
|
|
{
|
|
signal(SIGINT, handle_signal);
|
|
#ifndef _WIN32
|
|
signal(SIGHUP, handle_signal);
|
|
#endif
|
|
code = llarp_main_run(ctx);
|
|
llarp_main_free(ctx);
|
|
}
|
|
exit(code);
|
|
return code;
|
|
}
|