-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
47 lines (38 loc) · 1.12 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <boost/log/trivial.hpp>
#include <boost/optional/optional_io.hpp>
#include <sstream>
#include <algorithm>
#include "glue/options.h"
#include "beast/service.hpp"
#include "logging.h"
#include "cl_parser.h"
#include "recursive_i_notify_factory.h"
int main(int argc, char** argv) {
initLogging();
std::ostringstream sstr;
std::for_each(argv, argv + argc,
[&sstr, sep=""](const char *arg) mutable {
sstr << sep << arg; sep = " ";
}
);
BOOST_LOG_TRIVIAL(info) << sstr.str();
try {
auto options = parseCommandLine(argc, argv);
if (!options) { // called with '--help'
return EXIT_FAILURE;
}
BOOST_LOG_TRIVIAL(info) << "Run service with parameters: '" << options << "'\n";
setSeverityLevel(options->logSeverity);
runService(*options, RecursiveINotifyFactory{*options});
}
catch(std::exception& e) {
BOOST_LOG_TRIVIAL(error) << "error: " << e.what();
return EXIT_FAILURE;
}
catch(...) {
BOOST_LOG_TRIVIAL(error) << "Unknown exception";
return EXIT_FAILURE;
}
// (If we get here, it means we got a SIGINT or SIGTERM)
return EXIT_SUCCESS;
}