Psyllid  v1.12.4
Project 8 Data Acquisisition Software
psyllid.cc
Go to the documentation of this file.
1 /*
2  * psyllid.cc
3  *
4  * Created on: Feb 1, 2016
5  * Author: nsoblath
6  */
7 
8 #include "psyllid_constants.hh"
9 #include "psyllid_error.hh"
10 #include "psyllid_version.hh"
11 #include "run_server.hh"
12 #include "server_config.hh"
13 
14 #include "application.hh"
15 #include "logger.hh"
16 
17 using namespace psyllid;
18 
19 using std::string;
20 
21 LOGGER( plog, "psyllid" );
22 
23 int main( int argc, char** argv )
24 {
25  LINFO( plog, "Welcome to Psyllid\n\n" <<
26  "\t\t _/ _/ _/ _/ \n" <<
27  "\t\t _/_/_/ _/_/_/ _/ _/ _/ _/ _/_/_/ \n" <<
28  "\t\t _/ _/ _/_/ _/ _/ _/ _/ _/ _/ _/ \n" <<
29  "\t\t _/ _/ _/_/ _/ _/ _/ _/ _/ _/ _/ \n" <<
30  "\t\t _/_/_/ _/_/_/ _/_/_/ _/ _/ _/ _/_/_/ \n" <<
31  "\t\t _/ _/ \n" <<
32  "\t\t_/ _/_/ \n\n");
33 
34  try
35  {
36  // The application
37  scarab::main_app the_main;
38  run_server the_server;
39 
40  // Default configuration
41  the_main.default_config() = server_config();
42 
43  // The main execution callback
44  the_main.callback( [&](){ the_server.execute( the_main.master_config() ); } );
45 
46  // Command line options
47  the_main.add_config_option< std::string >( "-b,--broker", "amqp.broker", "Set the dripline broker address" );
48  the_main.add_config_option< unsigned >( "-p,--port", "amqp.broker-port", "Set the port for communication with the dripline broker" );
49  the_main.add_config_option< std::string >( "-e,--exchange", "amqp.exchange", "Set the exchange to send message on" );
50  the_main.add_config_option< std::string >( "-a,--auth-file", "amqp.auth-file", "Set the authentication file path" );
51  the_main.add_config_option< std::string >( "-s,--slack-queue", "amqp.slack-queue", "Set the queue name for Slack messages" );
52  the_main.add_config_flag< bool >( "--post-to-slack", "post-to-slack", "Flag for en/disabling posting to Slack" );
53  the_main.add_config_flag< bool >( "--activate-at-startup", "daq.activate-at-startup", "Flag to make Psyllid activate on startup" );
54  the_main.add_config_option< unsigned >( "-n,--n-files", "daq.n-files", "Number of files to be written in parallel" );
55  the_main.add_config_option< unsigned >( "-d,--duration", "daq.duration", "Run duration in ms" );
56  the_main.add_config_option< double >( "-m,--max-file-size-mb", "daq.max-file-size-mb", "Maximum file size in MB" );
57 
58  // Package version
59  the_main.set_version( new psyllid::version() );
60 
61  // Parse CL options and run the application
62  CLI11_PARSE( the_main, argc, argv );
63 
64  return the_server.get_return();
65  }
66  catch( scarab::error& e )
67  {
68  LERROR( plog, "configuration error: " << e.what() );
69  return RETURN_ERROR;
70  }
71  catch( psyllid::error& e )
72  {
73  LERROR( plog, "psyllid error: " << e.what() );
74  return RETURN_ERROR;
75  }
76  catch( std::exception& e )
77  {
78  LERROR( plog, "std::exception caught: " << e.what() );
79  return RETURN_ERROR;
80  }
81  catch( ... )
82  {
83  LERROR( plog, "unknown exception caught" );
84  return RETURN_ERROR;
85  }
86 
87  return RETURN_ERROR;
88 }
89 
90 
91 
92 
const char * what() const
static scarab::logger plog("batch_executor")
int main(int argc, char **argv)
Definition: psyllid.cc:23
int get_return() const
Definition: run_server.hh:98
LOGGER(plog, "egg_writer")
Contains default server configuration.
void execute(const scarab::param_node &a_config)
Definition: run_server.cc:48
Sets up daq_control, strea_manager and request_receiver. Registers request handles.
Definition: run_server.hh:47