Remove operation help.
[anna.git] / example / diameter / launcher / main.cpp
1 // ANNA - Anna is Not Nothingness Anymore                                                         //
2 //                                                                                                //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo                         //
4 //                                                                                                //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite                           //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
7
8
9 // Standard
10 #include <string>
11
12 // Project
13 #include <anna/core/core.hpp>
14 #include <anna/time/functions.hpp>
15 #include <anna/http/functions.hpp>
16
17 // Process
18 #include <Launcher.hpp>
19
20 // To calculate the current working directory and get an absolute path for traces:
21 #include <limits.h>
22 #include <unistd.h>
23
24
25 int main(int argc, const char** argv) {
26   anna::Logger::setLevel(anna::Logger::Warning);
27
28   // Current working directory and absolute trace path file:
29   char c_cwd[ PATH_MAX ];
30   std::string trace_file;
31   if (getcwd(c_cwd, sizeof(c_cwd)) != NULL) {
32     trace_file = c_cwd;
33     trace_file += "/launcher.trace";
34   } else {
35      perror("getcwd() error");
36      return 1;
37   }
38
39   anna::Logger::initialize("launcher", new TraceWriter(trace_file.c_str(), 2048000));
40   anna::time::functions::initialize(); // before application instantiation (it have a anna::time object)
41   anna::time::functions::setControlPoint(); // start control point (application lifetime)
42   Launcher app;
43   anna::http::functions::initialize();
44
45   try {
46     anna::CommandLine& commandLine(anna::CommandLine::instantiate());
47     // General
48     commandLine.add("services", anna::CommandLine::Argument::Mandatory, "Services xml path file. Shall be validated against dtd schema written on warning traces: 'Services DTD schema'. Empty string or \"null\" name, to start without services (check 'HELP.md' for more 'services').");
49     commandLine.add("trace", anna::CommandLine::Argument::Optional, "Trace level (emergency, alert, critical, error, warning, notice, information, debug, local0..local7)");
50     commandLine.add("cntDir", anna::CommandLine::Argument::Optional, "Counters directory. By default is the current execution directory. Warning: a counter file will be dump per record period; take care about the possible accumulation of files");
51     commandLine.add("tmDir", anna::CommandLine::Argument::Optional, "Test manager directory. By default is the current execution directory. Warning: report files could be dump during system testing (check 'HELP.md' for 'test|report|result'); take care about the possible accumulation of files");
52     commandLine.add("cntRecordPeriod", anna::CommandLine::Argument::Optional, "Counters record procedure period in milliseconds. If missing, default value of 300000 (5 minutes) will be assigned. Value of 0 disables the record procedure.");
53     commandLine.add("logStatisticSamples", anna::CommandLine::Argument::Optional, "Log statistics samples for the provided comma-separated concept id list, over './sample.<concept id>.csv' files. For example: \"1,2\" will log concepts 1 and 2. Reserved words \"all\"/\"none\" activates/deactivates all registered statistics concept identifiers. That ids are shown at context dump (check 'HELP.md' to get it).");
54     commandLine.add("disableLogs", anna::CommandLine::Argument::Optional, "Overrides every node configuration regarding traffic log in order to disable it and ease production or system test startup.", false);
55
56     // Communications
57     commandLine.add("reconnectionPeriod", anna::CommandLine::Argument::Optional, "Milliseconds to recover diameter client-session when server connection has been broken. If missing, default value of 10000 will be assigned");
58     commandLine.add("httpServer", anna::CommandLine::Argument::Optional, "HTTP Management interface address (using i.e. curl tool) in '<address>:<port>' format. For example: 10.20.30.40:8080");
59     commandLine.add("httpServerShared", anna::CommandLine::Argument::Optional, "Enables shared bind for HTTP Management interface address. It would be useful i.e. to allow a great amount of curl operations per second", false);
60
61     // Automatic error answer
62     commandLine.add("ignoreErrors", anna::CommandLine::Argument::Optional, "Local server skips requests errors analysis which would prepare automatic answers for them when a problem is found. If no answer is programmed and entity is configured, a failed request would be forwarded (delegates at the end point) even if this parameter is missing", false);
63
64     commandLine.initialize(argv, argc);
65     commandLine.verify();
66     std::cout << commandLine.asString() << std::endl;
67     app.start();
68   } catch(anna::Exception& ex) {
69     std::cout << ex.asString() << std::endl;
70   }
71
72   return 0;
73 }
74