ddschildserver.cc File Reference

#include <cstdlib>
#include <unistd.h>
#include "TROOT.h"
#include "TSystem.h"
#include "MessageService/MsgService.h"
#include "Dispatcher/DDSChildServer.h"

Go to the source code of this file.

Functions

TROOT root ("ddschildserver","MINOS Data Dispatcher System childserver")
 CVSID ("$Id: ddschildserver.cc,v 1.7 2009/02/28 21:46:12 gmieg Exp $")
int main (int argc, char **argv)

Function Documentation

CVSID ( "$Id: ddschildserver.  cc,
v 1.7 2009/02/28 21:46:12 gmieg Exp $"   
)
int main ( int  argc,
char **  argv 
)

Definition at line 31 of file ddschildserver.cc.

References gSystem(), MsgService::Instance(), DDSChildServer::IsValid(), Msg::kDebug, Msg::kFatal, Msg::kFile, Msg::kInfo, Msg::kLine, Msg::kName, Msg::kNLogLevel, Msg::kTime, Msg::kVerbose, Msg::kWarning, MSG, and Dbi::SetLogLevel().

00031                                 {
00032 
00033   pid_t pid = gSystem -> GetPid(); //get process id for identification purposes
00034 
00035 
00036   gROOT -> SetBatch(kTRUE);
00037 
00038   //  gSystem -> Sleep(60*1000); // sleep to give debugger time to attach
00039 
00040   // Process arguments
00041   if (argc < 5) {
00042     cerr << pid << ":Error: ddschildserver called with missing argument.\n" 
00043     << "Usage:\n"
00044     << "ddschildserver <socketdescriptor> <niceinc> <loglevel> <maxinactive>." 
00045     << endl;
00046     return 1;
00047   }
00048 
00049   // Connected socket descriptor.
00050   Int_t sockfd = atoi(argv[1]);
00051   // Nice incrementation for this child server
00052   Int_t niceincr = atoi(argv[2]);
00053   nice(niceincr); // adjusts the priority of this child server by niceincr.
00054 
00055   // Customize message service 
00056   Int_t logLevel = atoi(argv[3]);
00057   MsgStream* msdds = MsgService::Instance() -> GetStream("DDS");
00058   MsgStream* msper = MsgService::Instance() -> GetStream("Per");
00059   msdds -> SetLogLevel(logLevel);
00060   // require time stamping for all log levels equal to or above this
00061   for (int i = logLevel; i < Msg::kNLogLevel; i++) {
00062     msdds -> AddFormat(i,Msg::kTime);
00063     msper -> AddFormat(i,Msg::kTime);
00064   }
00065   msdds-> RemoveFormat(Msg::kWarning,Msg::kName+Msg::kFile+Msg::kLine);
00066   msdds-> RemoveFormat(Msg::kInfo,Msg::kName+Msg::kFile+Msg::kLine);
00067   msdds-> RemoveFormat(Msg::kDebug,Msg::kName+Msg::kFile+Msg::kLine);
00068   msdds-> RemoveFormat(Msg::kVerbose,Msg::kName+Msg::kFile+Msg::kLine);
00069 
00070   // Customize max inactive time limit (sec)
00071   Int_t maxinactive = atoi(argv[4]);
00072 
00073   // Create a DDSChildServer object with the connected socket descriptor
00074   DDSChildServer *cs = new DDSChildServer(sockfd,maxinactive);
00075 
00076   if (! cs->IsValid() ) {
00077     // Error in creation of child server
00078     MSG("DDS",Msg::kFatal) << "CS_" << pid 
00079     << ": Error in creation of child server. Program terminating." <<endl;
00080     return 1;
00081   }
00082 
00083   TDatime starttime;
00084   MSG("DDS",Msg::kInfo) << "CS_" << pid << ": child server created on " 
00085        << starttime.AsString() << endl;
00086   MSG("DDS",Msg::kInfo) << cs << endl;
00087 
00088 // Run the main loop to listen for and process client requests
00089 // The child server will stay in this loop until it receives a 
00090 // DDS::kShutdown message from a connected client 
00091   Int_t rc = cs -> Run();
00092 
00093 // Print final stats from the child server socket
00094   TDatime endtime;
00095   MSG("DDS",Msg::kInfo) << "CS_" << pid << ": child server shutdown on " << endtime.AsString() << endl;
00096 
00097 // delete child server socket
00098   delete cs;
00099 
00100   return rc;
00101 
00102 }

TROOT root ( "ddschildserver"  ,
"MINOS Data Dispatcher System childserver"   
)

Generated on 16 Apr 2018 for loon by  doxygen 1.6.1