A simple server illustrating several customisations
#include <chrono>
#include <cstdlib>
namespace
{
{
static const char* const launch_child_opt = "launch-client";
static const char* const launch_client_descr = "system() command to launch client";
{
if (options->is_set(launch_child_opt))
{
auto ignore = std::system((options->get<std::string>(launch_child_opt) + "&").c_str());
(void)(ignore);
}
});
}
{
static const char* const timeout_opt = "timeout";
static const char* const timeout_descr = "Seconds to run before exiting";
{
if (options->is_set(timeout_opt))
{
static auto const exit_action = server.
the_main_loop()->notify_in(
std::chrono::seconds(options->get<int>(timeout_opt)),
[&] { server.stop(); });
}
});
}
}
int main(
int argc,
char const* argv[])
try
{
add_launcher_option_to(server);
add_timeout_option_to(server);
std::atomic<bool> test_failed{false};
if (test_failed) return EXIT_FAILURE;
}
catch (...)
{
return EXIT_FAILURE;
}
Copyright © 2012,2013 Canonical Ltd.
Generated on Tue Mar 24 16:15:19 UTC 2015