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()->create_alarm([&server] { server.
stop(); });
exit_action->reschedule_in(std::chrono::seconds(options->get<int>(timeout_opt)));
}
});
}
}
int main(
int argc,
char const* argv[])
try
{
add_launcher_option_to(server);
add_timeout_option_to(server);
{
return EXIT_FAILURE;
}
}
catch (...)
{
return EXIT_FAILURE;
}
Copyright © 2012-2015 Canonical Ltd.
Generated on Thu Oct 8 16:20:16 UTC 2015