source: trunk/FACT++/src/triggerschedule.cc@ 15658

Last change on this file since 15658 was 11578, checked in by tbretz, 13 years ago
Moved some part of the initialization from main to Configure::DoParse
File size: 2.2 KB
Line 
1#include <iostream>
2#include <dic.hxx>
3
4#include "Dim.h"
5#include "Configuration.h"
6
7using namespace std;
8
9void SetupConfiguration(Configuration &conf)
10{
11 po::options_description config("Configuration");
12 config.add_options()
13 ("dns", var<string>("localhost"), "Dim nameserver host name (Overwites DIM_DNS_NODE environment variable)")
14 ("schedule-database-name", var<string>(), "Database name for scheduling")
15 ;
16
17 po::positional_options_description p;
18 p.add("schedule-database-name", 1); // The first positional options
19
20 conf.AddEnv("dns", "DIM_DNS_NODE");
21 conf.AddOptions(config);
22 conf.SetArgumentPositions(p);
23}
24
25void PrintUsage()
26{
27 cout <<
28 "The triggerschedule triggers the scheduler.\n"
29 "\n"
30 "The default is that the program is started without user intercation. "
31 "All actions are supposed to arrive as DimCommands. Using the -c "
32 "option, a local shell can be initialized. With h or help a short "
33 "help message about the usuage can be brought to the screen.\n"
34 "\n"
35 "Usage: triggerschedule [-c type] [OPTIONS] <schedule-database-name>\n"
36 " or: triggerschedule [OPTIONS] <schedule-database-name>\n";
37 cout << endl;
38}
39
40void PrintHelp()
41{
42 cout <<
43 "\n"
44 "The method sendCommand(...) will wait for the command to "
45 "be actualy sent to the server and return a completion code "
46 "of:\n"
47 " 0 - if it was successfully sent.\n"
48 " 1 - if it couldn't be delivered.\n "
49 << endl;
50 /* Additional help text which is printed after the configuration
51 options goes here */
52}
53
54int main(int argc, const char* argv[])
55{
56 Configuration conf(argv[0]);
57 conf.SetPrintUsage(PrintUsage);
58 SetupConfiguration(conf);
59
60 if (!conf.DoParse(argc, argv, PrintHelp))
61 return -1;
62
63 const string dbname = conf.Get<string>("schedule-database-name");
64
65 Dim::Setup(conf.Get<string>("dns"));
66
67 const int rc = DimClient::sendCommand("SCHEDULER/SCHEDULE", dbname.c_str());
68 if (!rc)
69 cerr << "Sending failed!" << endl;
70 else
71 cout << "Command issued successfully." << endl;
72
73 return !rc;
74}
Note: See TracBrowser for help on using the repository browser.