14 static int joedb_server(
int argc,
char **argv)
23 std::cerr <<
"usage: " << argv[0];
24 std::cerr <<
" [--socket <endpoint_path>] [--timeout t]";
25 client_parser.print_help(std::cerr);
27The timeout is the time (in seconds) during which a client lock is kept.
280 (the default) means there is no timeout, and the lock is kept until the
29client unlocks or is disconnected. A client that timed out is not disconnected,
30and can still push data: the push will succeed only if there is no conflict.
37 std::string_view endpoint_base(
"joedb");
38 for (
int i = 1; i < argc; i++)
40 const std::string_view v(argv[i]);
41 if (v.size() > 6 && v.compare(v.size() - 6, 6,
".joedb") == 0)
44 endpoint_base.remove_suffix(6);
48 std::string endpoint_path = std::string(endpoint_base) +
".sock";
50 if (index + 1 < argc && std::strcmp(argv[index],
"--socket") == 0)
52 endpoint_path = argv[index + 1];
57 if (index + 1 < argc && std::strcmp(argv[index],
"--timeout") == 0)
59 timeout = uint32_t(std::atoi(argv[index + 1]));
63 Client &client = client_parser.parse(argc - index, argv + index);
65 IO_Context_Wrapper io_context_wrapper;
67 std::cout <<
"Creating server (endpoint_path = " << endpoint_path;
68 std::cout <<
"; timeout = " << timeout <<
")\n";
73 io_context_wrapper.io_context,
75 std::chrono::seconds(timeout),
79 io_context_wrapper.run();
86int main(
int argc,
char **argv)
@ write_existing_or_create_new
either write_existing or create_new depending on whether the file exists. Racy in Posix,...
int main_exception_catcher(int(*main)(int, char **), int argc, char **argv)
Catch exception from main.