bes  Updated for version 3.19.1
ServerApp.cc
1 // ServerApp.cc
2 
3 // This file is part of bes, A C++ back-end server implementation framework
4 // for the OPeNDAP Data Access Protocol.
5 
6 // Copyright (c) 2004-2009 University Corporation for Atmospheric Research
7 // Author: Patrick West <pwest@ucar.edu> and Jose Garcia <jgarcia@ucar.edu>
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
13 //
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
18 //
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 //
23 // You can contact University Corporation for Atmospheric Research at
24 // 3080 Center Green Drive, Boulder, CO 80301
25 
26 // (c) COPYRIGHT University Corporation for Atmospheric Research 2004-2005
27 // Please read the full copyright statement in the file COPYRIGHT_UCAR.
28 //
29 // Authors:
30 // pwest Patrick West <pwest@ucar.edu>
31 // jgarcia Jose Garcia <jgarcia@ucar.edu>
32 
33 #include <unistd.h>
34 #include <signal.h>
35 #include <sys/wait.h> // for wait
36 #include <sys/types.h>
37 
38 #include <iostream>
39 #include <fstream>
40 #include <sstream>
41 #include <cstring>
42 #include <cstdlib>
43 #include <cerrno>
44 
45 #include <libxml/xmlmemory.h>
46 
47 using std::cout;
48 using std::cerr;
49 using std::endl;
50 using std::ios;
51 using std::ostringstream;
52 using std::ofstream;
53 
54 #include "config.h"
55 
56 #include "ServerApp.h"
57 #include "ServerExitConditions.h"
58 #include "TheBESKeys.h"
59 #include "BESLog.h"
60 #include "SocketListener.h"
61 #include "TcpSocket.h"
62 #include "UnixSocket.h"
63 #include "BESServerHandler.h"
64 #include "BESError.h"
65 #include "PPTServer.h"
66 #include "BESMemoryManager.h"
67 #include "BESDebug.h"
68 #include "BESCatalogUtils.h"
69 #include "BESServerUtils.h"
70 
71 #include "BESDefaultModule.h"
72 #include "BESXMLDefaultCommands.h"
73 #include "BESDaemonConstants.h"
74 
75 static int session_id = 0;
76 
77 // These are set to 1 by their respective handlers and then processed in the
78 // signal processing loop.
79 static volatile sig_atomic_t sigchild = 0;
80 static volatile sig_atomic_t sigpipe = 0;
81 static volatile sig_atomic_t sigterm = 0;
82 static volatile sig_atomic_t sighup = 0;
83 
84 // Set in ServerApp::initialize().
85 // Added jhrg 9/22/15
86 static volatile int master_listener_pid = -1;
87 
88 static string bes_exit_message(int cpid, int stat)
89 {
90  ostringstream oss;
91  oss << "beslistener child pid: " << cpid;
92  if (WIFEXITED(stat)) { // exited via exit()?
93  oss << " exited with status: " << WEXITSTATUS(stat);
94  }
95  else if (WIFSIGNALED(stat)) { // exited via a signal?
96  oss << " exited with signal: " << WTERMSIG(stat);
97 #ifdef WCOREDUMP
98  if (WCOREDUMP(stat)) oss << " and a core dump!";
99 #endif
100  }
101  else {
102  oss << " exited, but I have no clue as to why";
103  }
104 
105  return oss.str();
106 }
107 
108 // These two functions duplicate code in daemon.cc
109 static void block_signals()
110 {
111  sigset_t set;
112  sigemptyset(&set);
113  sigaddset(&set, SIGCHLD);
114  sigaddset(&set, SIGHUP);
115  sigaddset(&set, SIGTERM);
116  sigaddset(&set, SIGPIPE);
117 
118  if (sigprocmask(SIG_BLOCK, &set, 0) < 0) {
119  throw BESInternalError(string("sigprocmask error: ") + strerror(errno) + " while trying to block signals.",
120  __FILE__, __LINE__);
121  }
122 }
123 
124 static void unblock_signals()
125 {
126  sigset_t set;
127  sigemptyset(&set);
128  sigaddset(&set, SIGCHLD);
129  sigaddset(&set, SIGHUP);
130  sigaddset(&set, SIGTERM);
131  sigaddset(&set, SIGPIPE);
132 
133  if (sigprocmask(SIG_UNBLOCK, &set, 0) < 0) {
134  throw BESInternalError(string("sigprocmask error: ") + strerror(errno) + " while trying to unblock signals.",
135  __FILE__, __LINE__);
136  }
137 }
138 
139 // I moved the signal handlers here so that signal processing would be simpler
140 // and no library calls would be made to functions that are not 'asynch safe'.
141 // This was the fix for ticket 2025 and friends (the zombie process problem).
142 // jhrg 3/3/14
143 
144 // This is needed so that the master bes listener will get the exit status of
145 // all of the child bes listeners (preventing them from becoming zombies).
146 static void CatchSigChild(int sig)
147 {
148  if (sig == SIGCHLD) {
149  sigchild = 1;
150  }
151 }
152 
153 // If the HUP signal is sent to the master beslistener, it should exit and
154 // return a value indicating to the besdaemon that it should be restarted.
155 // This also has the side-affect of re-reading the configuration file.
156 static void CatchSigHup(int sig)
157 {
158  if (sig == SIGHUP) {
159  sighup = 1;
160  }
161 }
162 
163 static void CatchSigPipe(int sig)
164 {
165  if (sig == SIGPIPE) {
166  // When a child listener catches SIGPIPE it is because of a
167  // failure on one of its I/O connections - file I/O or, more
168  // likely, network I/O. I have found that C++ ostream objects
169  // seem to 'hide' sigpipe so that a child listener will run
170  // for some time after the client has dropped the
171  // connection. Whether this is from buffering or some other
172  // problem, the situation happens when either the remote
173  // client to exits (e.g., curl) or when Tomcat is stopped
174  // using SIGTERM. So, even though the normal behavior for a
175  // Unix daemon is to look at error codes from write(), etc.,
176  // and exit based on those, this code exits whenever the child
177  // listener catches SIGPIPE. However, if this is the Master
178  // listener, allow the processing loop to handle this signal
179  // and do not exit. jhrg 9/22/15
180  if (getpid() != master_listener_pid) {
181  (*BESLog::TheLog()) << "Child listener (PID: " << getpid() << ") caught SIGPIPE (master listener PID: "
182  << master_listener_pid << "). Child listener Exiting." << endl;
183 
184  // cleanup code here; only the Master listener should run the code
185  // in ServerApp::terminate(); do nothing for cleanup for a child
186  // listener. jhrg 9/22/15
187 
188  // Note that exit() is not safe for use in a signal
189  // handler, so we fallback to the default behavior, which
190  // is to exit.
191  signal(sig, SIG_DFL);
192  raise(sig);
193  }
194  else {
195  LOG("Master listener (PID: " << getpid() << ") caught SIGPIPE." << endl);
196 
197  sigpipe = 1;
198  }
199  }
200 }
201 
202 // This is the default signal sent by 'kill'; when the master beslistener gets
203 // this signal it should stop. besdaemon should not try to start a new
204 // master beslistener.
205 static void CatchSigTerm(int sig)
206 {
207  if (sig == SIGTERM) {
208  sigterm = 1;
209  }
210 }
211 
220 static void register_signal_handlers()
221 {
222  struct sigaction act;
223  sigemptyset(&act.sa_mask);
224  sigaddset(&act.sa_mask, SIGCHLD);
225  sigaddset(&act.sa_mask, SIGPIPE);
226  sigaddset(&act.sa_mask, SIGTERM);
227  sigaddset(&act.sa_mask, SIGHUP);
228  act.sa_flags = 0;
229 #ifdef SA_RESTART
230  BESDEBUG("beslistener", "beslistener: setting restart for sigchld." << endl);
231  act.sa_flags |= SA_RESTART;
232 #endif
233 
234  BESDEBUG("beslistener", "beslistener: Registering signal handlers ... " << endl);
235 
236  act.sa_handler = CatchSigChild;
237  if (sigaction(SIGCHLD, &act, 0))
238  throw BESInternalFatalError("Could not register a handler to catch beslistener child process status.", __FILE__,
239  __LINE__);
240 
241  act.sa_handler = CatchSigPipe;
242  if (sigaction(SIGPIPE, &act, 0) < 0)
243  throw BESInternalFatalError("Could not register a handler to catch beslistener pipe signal.", __FILE__,
244  __LINE__);
245 
246  act.sa_handler = CatchSigTerm;
247  if (sigaction(SIGTERM, &act, 0) < 0)
248  throw BESInternalFatalError("Could not register a handler to catch beslistener terminate signal.", __FILE__,
249  __LINE__);
250 
251  act.sa_handler = CatchSigHup;
252  if (sigaction(SIGHUP, &act, 0) < 0)
253  throw BESInternalFatalError("Could not register a handler to catch beslistener hup signal.", __FILE__,
254  __LINE__);
255 
256  BESDEBUG("beslistener", "beslistener: OK" << endl);
257 }
258 
259 ServerApp::ServerApp() :
260  BESModuleApp(), _portVal(0), _gotPort(false), _IPVal(""), _gotIP(false), _unixSocket(""), _secure(false), _mypid(0), _ts(0), _us(0), _ps(0)
261 {
262  _mypid = getpid();
263 }
264 
265 ServerApp::~ServerApp()
266 {
267  delete TheBESKeys::TheKeys();
268 
269  BESCatalogUtils::delete_all_catalogs();
270 }
271 
272 int ServerApp::initialize(int argc, char **argv)
273 {
274  int c = 0;
275  bool needhelp = false;
276  string dashi;
277  string dashc;
278  string dashd = "";
279 
280  // If you change the getopt statement below, be sure to make the
281  // corresponding change in daemon.cc and besctl.in
282  while ((c = getopt(argc, argv, "hvsd:c:p:u:i:r:H:")) != -1) {
283  switch (c) {
284  case 'i':
285  dashi = optarg;
286  break;
287  case 'c':
288  dashc = optarg;
289  break;
290  case 'r':
291  break; // we can ignore the /var/run directory option here
292  case 'p':
293  _portVal = atoi(optarg);
294  _gotPort = true;
295  break;
296  case 'H':
297  _IPVal = optarg;
298  _gotIP = true;
299  break;
300  case 'u':
301  _unixSocket = optarg;
302  break;
303  case 'd':
304  dashd = optarg;
305  // BESDebug::SetUp(optarg);
306  break;
307  case 'v':
308  BESServerUtils::show_version(BESApp::TheApplication()->appName());
309  break;
310  case 's':
311  _secure = true;
312  break;
313  case 'h':
314  case '?':
315  default:
316  needhelp = true;
317  break;
318  }
319  }
320 
321  // before we can do any processing, log any messages, initialize any
322  // modules, do anything, we need to determine where the BES
323  // configuration file lives. From here we get the name of the log
324  // file, group and user id, and information that the modules will
325  // need to run properly.
326 
327  // If the -c option was passed, set the config file name in TheBESKeys
328  if (!dashc.empty()) {
329  TheBESKeys::ConfigFile = dashc;
330  }
331 
332  // If the -c option was not passed, but the -i option
333  // was passed, then use the -i option to construct
334  // the path to the config file
335  if (dashc.empty() && !dashi.empty()) {
336  if (dashi[dashi.length() - 1] != '/') {
337  dashi += '/';
338  }
339  string conf_file = dashi + "etc/bes/bes.conf";
340  TheBESKeys::ConfigFile = conf_file;
341  }
342 
343  if (!dashd.empty()) BESDebug::SetUp(dashd);
344 
345  // register the two debug context for the server and ppt. The
346  // Default Module will register the bes context.
347  BESDebug::Register("server");
348  BESDebug::Register("ppt");
349 
350  // Because we are now running as the user specified in the
351  // configuration file, we won't be able to listen on system ports.
352  // If this is a problem, we may need to move this code above setting
353  // the user and group ids.
354  bool found = false;
355  string port_key = "BES.ServerPort";
356  if (!_gotPort) {
357  string sPort;
358  try {
359  TheBESKeys::TheKeys()->get_value(port_key, sPort, found);
360  }
361  catch (BESError &e) {
362  string err = string("FAILED: ") + e.get_message();
363  cerr << err << endl;
364  LOG(err << endl);
365  exit(SERVER_EXIT_FATAL_CANNOT_START);
366  }
367  if (found) {
368  _portVal = atoi(sPort.c_str());
369  if (_portVal != 0) {
370  _gotPort = true;
371  }
372  }
373  }
374 
375  found = false;
376  string ip_key = "BES.ServerIP";
377  if (!_gotIP) {
378  try {
379  TheBESKeys::TheKeys()->get_value(ip_key, _IPVal, found);
380  }
381  catch (BESError &e) {
382  string err = string("FAILED: ") + e.get_message();
383  cerr << err << endl;
384  LOG(err << endl);
385  exit(SERVER_EXIT_FATAL_CANNOT_START);
386  }
387 
388  if (found) {
389  _gotIP = true;
390  }
391  }
392 
393  found = false;
394  string socket_key = "BES.ServerUnixSocket";
395  if (_unixSocket == "") {
396  try {
397  TheBESKeys::TheKeys()->get_value(socket_key, _unixSocket, found);
398  }
399  catch (BESError &e) {
400  string err = string("FAILED: ") + e.get_message();
401  cerr << err << endl;
402  LOG(err << endl);
403  exit(SERVER_EXIT_FATAL_CANNOT_START);
404  }
405  }
406 
407  if (!_gotPort && _unixSocket == "") {
408  string msg = "Must specify a tcp port or a unix socket or both\n";
409  msg += "Please specify on the command line with -p <port>";
410  msg += " and/or -u <unix_socket>\n";
411  msg += "Or specify in the bes configuration file with " + port_key + " and/or " + socket_key + "\n";
412  cout << endl << msg;
413  LOG(msg << endl);
414  BESServerUtils::show_usage(BESApp::TheApplication()->appName());
415  }
416 
417  found = false;
418  if (_secure == false) {
419  string key = "BES.ServerSecure";
420  string isSecure;
421  try {
422  TheBESKeys::TheKeys()->get_value(key, isSecure, found);
423  }
424  catch (BESError &e) {
425  string err = string("FAILED: ") + e.get_message();
426  cerr << err << endl;
427  LOG(err << endl);
428  exit(SERVER_EXIT_FATAL_CANNOT_START);
429  }
430  if (isSecure == "Yes" || isSecure == "YES" || isSecure == "yes") {
431  _secure = true;
432  }
433  }
434 
435  BESDEBUG("beslistener", "beslistener: initializing default module ... " << endl);
436  BESDefaultModule::initialize(argc, argv);
437  BESDEBUG("beslistener", "beslistener: done initializing default module" << endl);
438 
439  BESDEBUG("beslistener", "beslistener: initializing default commands ... " << endl);
441  BESDEBUG("beslistener", "beslistener: done initializing default commands" << endl);
442 
443  // This will load and initialize all of the modules
444  BESDEBUG("beslistener", "beslistener: initializing loaded modules ... " << endl);
445  int ret = BESModuleApp::initialize(argc, argv);
446  BESDEBUG("beslistener", "beslistener: done initializing loaded modules" << endl);
447 
448  BESDEBUG("beslistener", "beslistener: initialized settings:" << *this);
449 
450  if (needhelp) {
451  BESServerUtils::show_usage(BESApp::TheApplication()->appName());
452  }
453 
454  // This sets the process group to be ID of this process. All children
455  // will get this GID. Then use killpg() to send a signal to this process
456  // and all of the children.
457  session_id = setsid();
458  BESDEBUG("beslistener", "beslistener: The master beslistener session id (group id): " << session_id << endl);
459 
460  master_listener_pid = getpid();
461  BESDEBUG("beslistener", "beslistener: The master beslistener Process id: " << master_listener_pid << endl);
462 
463  return ret;
464 }
465 
467 {
468  try {
469  BESDEBUG("beslistener", "beslistener: initializing memory pool ... " << endl);
470  BESMemoryManager::initialize_memory_pool();
471  BESDEBUG("beslistener", "OK" << endl);
472 
473  SocketListener listener;
474  if (_portVal) {
475  if (!_IPVal.empty())
476  _ts = new TcpSocket(_IPVal, _portVal);
477  else
478  _ts = new TcpSocket(_portVal);
479 
480  listener.listen(_ts);
481 
482  BESDEBUG("beslistener", "beslistener: listening on port (" << _portVal << ")" << endl);
483 
484  // Write to stdout works because the besdaemon is listening on the
485  // other end of a pipe where the pipe fd[1] has been dup2'd to
486  // stdout. See daemon.cc:start_master_beslistener.
487  // NB BESLISTENER_PIPE_FD is 1 (stdout)
488  int status = BESLISTENER_RUNNING;
489  int res = write(BESLISTENER_PIPE_FD, &status, sizeof(status));
490 
491  if (res == -1) {
492  LOG("Master listener could not send status to daemon: " << strerror(errno) << endl);
493  ::exit(SERVER_EXIT_FATAL_CANNOT_START);
494  }
495  }
496 
497  if (!_unixSocket.empty()) {
498  _us = new UnixSocket(_unixSocket);
499  listener.listen(_us);
500  BESDEBUG("beslistener", "beslistener: listening on unix socket (" << _unixSocket << ")" << endl);
501  }
502 
503  BESServerHandler handler;
504 
505  _ps = new PPTServer(&handler, &listener, _secure);
506 
507  register_signal_handlers();
508 
509  // Loop forever, processing signals and running the code in PPTServer::initConnection().
510  // NB: The code in initConnection() used to loop forever, but I moved that out to here
511  // so the signal handlers could be in this class. The PPTServer::initConnection() method
512  // is also used by daemon.cc but this class (ServerApp; the beslistener) and the besdaemon
513  // need to do different things for the signals like HUP and TERM, so they cannot share
514  // the signal processing code. One fix for the problem described in ticket 2025 was to
515  // move the signal handlers into PPTServer. Changing how the 'forever' loops are organized
516  // and keeping the signal processing code here (and in daemon.cc) is another solution that
517  // preserves the correct behavior of the besdaemon, too. jhrg 3/5/14
518  while (true) {
519  block_signals();
520 
521  if (sigterm | sighup | sigchild | sigpipe) {
522  int stat;
523  pid_t cpid;
524  while ((cpid = wait4(0 /*any child in the process group*/, &stat, WNOHANG, 0/*no rusage*/)) > 0) {
525  _ps->decr_num_children();
526  if (sigpipe) {
527  LOG("Master listener caught SISPIPE from child: " << cpid << endl);
528  }
529 
530  BESDEBUG("ppt2",
531  bes_exit_message(cpid, stat) << "; num children: " << _ps->get_num_children() << endl);
532  }
533  }
534 
535  if (sighup) {
536  BESDEBUG("ppt2", "Master listener caught SIGHUP, exiting with SERVER_EXIT_RESTART" << endl);
537 
538  LOG("Master listener caught SIGHUP, exiting with SERVER_EXIT_RESTART" << endl);
539  ::exit(SERVER_EXIT_RESTART);
540  }
541 
542  if (sigterm) {
543  BESDEBUG("ppt2", "Master listener caught SIGTERM, exiting with SERVER_NORMAL_SHUTDOWN" << endl);
544 
545  LOG("Master listener caught SIGTERM, exiting with SERVER_NORMAL_SHUTDOWN" << endl);
546  ::exit(SERVER_EXIT_NORMAL_SHUTDOWN);
547  }
548 
549  sigchild = 0; // Only reset this signal, all others cause an exit/restart
550  unblock_signals();
551 
552  // This is where the 'child listener' is started. This method will call
553  // BESServerHandler::handle(...) that will, in turn, fork. The child process
554  // becomes the 'child listener' that actually processes a request.
555  _ps->initConnection();
556  }
557 
558  _ps->closeConnection();
559  }
560  catch (BESError &se) {
561  BESDEBUG("beslistener", "beslistener: caught BESError (" << se.get_message() << ")" << endl);
562 
563  LOG(se.get_message() << endl);
564  int status = SERVER_EXIT_FATAL_CANNOT_START;
565  write(BESLISTENER_PIPE_FD, &status, sizeof(status));
566  close(BESLISTENER_PIPE_FD);
567  return 1;
568  }
569  catch (...) {
570  LOG("caught unknown exception initializing sockets" << endl);
571  int status = SERVER_EXIT_FATAL_CANNOT_START;
572  write(BESLISTENER_PIPE_FD, &status, sizeof(status));
573  close(BESLISTENER_PIPE_FD);
574  return 1;
575  }
576 
577  close(BESLISTENER_PIPE_FD);
578  return 0;
579 }
580 
582 {
583  pid_t apppid = getpid();
584  if (apppid == _mypid) {
585  // These are all safe to call in a signalhandler
586  if (_ps) {
587  _ps->closeConnection();
588  delete _ps;
589  }
590  if (_ts) {
591  _ts->close();
592  delete _ts;
593  }
594  if (_us) {
595  _us->close();
596  delete _us;
597  }
598 
599  // Do this in the reverse order that it was initialized. So
600  // terminate the loaded modules first, then the default
601  // commands, then the default module.
602 
603  // These are not safe to call in a signal handler
604  BESDEBUG("beslistener", "beslistener: terminating loaded modules ... " << endl);
606  BESDEBUG("beslistener", "beslistener: done terminating loaded modules" << endl);
607 
608  BESDEBUG("beslistener", "beslistener: terminating default commands ... " << endl);
610  BESDEBUG("beslistener", "beslistener: done terminating default commands ... " << endl);
611 
612  BESDEBUG("beslistener", "beslistener: terminating default module ... " << endl);
613  BESDefaultModule::terminate();
614  BESDEBUG("beslistener", "beslistener: done terminating default module ... " << endl);
615 
616  xmlCleanupParser();
617  }
618  return sig;
619 }
620 
627 void ServerApp::dump(ostream &strm) const
628 {
629  strm << BESIndent::LMarg << "ServerApp::dump - (" << (void *) this << ")" << endl;
630  BESIndent::Indent();
631  strm << BESIndent::LMarg << "got IP? " << _gotIP << endl;
632  strm << BESIndent::LMarg << "IP: " << _IPVal << endl;
633  strm << BESIndent::LMarg << "got port? " << _gotPort << endl;
634  strm << BESIndent::LMarg << "port: " << _portVal << endl;
635  strm << BESIndent::LMarg << "unix socket: " << _unixSocket << endl;
636  strm << BESIndent::LMarg << "is secure? " << _secure << endl;
637  strm << BESIndent::LMarg << "pid: " << _mypid << endl;
638  if (_ts) {
639  strm << BESIndent::LMarg << "tcp socket:" << endl;
640  BESIndent::Indent();
641  _ts->dump(strm);
642  BESIndent::UnIndent();
643  }
644  else {
645  strm << BESIndent::LMarg << "tcp socket: null" << endl;
646  }
647  if (_us) {
648  strm << BESIndent::LMarg << "unix socket:" << endl;
649  BESIndent::Indent();
650  _us->dump(strm);
651  BESIndent::UnIndent();
652  }
653  else {
654  strm << BESIndent::LMarg << "unix socket: null" << endl;
655  }
656  if (_ps) {
657  strm << BESIndent::LMarg << "ppt server:" << endl;
658  BESIndent::Indent();
659  _ps->dump(strm);
660  BESIndent::UnIndent();
661  }
662  else {
663  strm << BESIndent::LMarg << "ppt server: null" << endl;
664  }
665  BESModuleApp::dump(strm);
666  BESIndent::UnIndent();
667 }
668 
669 int main(int argc, char **argv)
670 {
671  try {
672  ServerApp app;
673  return app.main(argc, argv);
674  }
675  catch (BESError &e) {
676  cerr << "Caught unhandled exception: " << endl;
677  cerr << e.get_message() << endl;
678  return 1;
679  }
680  catch (...) {
681  cerr << "Caught unhandled, unknown exception" << endl;
682  return 1;
683  }
684  return 0;
685 }
686 
exception thrown if an internal error is found and is fatal to the BES
exception thrown if inernal error encountered
static void Register(const std::string &flagName)
register the specified debug flag
Definition: BESDebug.h:141
virtual std::string get_message()
get the error message for this exception
Definition: BESError.h:97
static void SetUp(const std::string &values)
Sets up debugging for the bes.
Definition: BESDebug.cc:64
virtual int terminate(int sig=0)
clean up after the application
void get_value(const string &s, string &val, bool &found)
Retrieve the value of a given key, if set.
Definition: TheBESKeys.cc:422
static int terminate(void)
Removes the default set of BES XML commands from the list of possible commands.
static int initialize(int argc, char **argv)
Loads the default set of BES XML commands.
Abstract exception class for the BES with basic string message.
Definition: BESError.h:56
static TheBESKeys * TheKeys()
Definition: TheBESKeys.cc:62
virtual int main(int argC, char **argV)
main routine, the main entry point for any BES applications.
Definition: BESApp.cc:53
virtual void dump(ostream &strm) const
dumps information about this object
Definition: ServerApp.cc:627
virtual int terminate(int sig=0)
clean up after the application
Definition: ServerApp.cc:581
virtual void dump(ostream &strm) const
dumps information about this object
virtual int initialize(int argC, char **argV)
Load and initialize any BES modules.
Definition: ServerApp.cc:272
Base application object for all BES applications.
Definition: BESModuleApp.h:59
virtual int initialize(int argC, char **argV)
Load and initialize any BES modules.
Definition: BESModuleApp.cc:70
static BESApp * TheApplication(void)
Returns the BESApp application object for this application.
Definition: BESApp.h:143
virtual int run()
The body of the application, implementing the primary functionality of the BES application.
Definition: ServerApp.cc:466
static string ConfigFile
Definition: TheBESKeys.h:145