#include "main.h"
#include "Repository.h"
#include "Persist.h"
#include "daemon.h"
Include dependency graph for main.cc:
Go to the source code of this file.
Functions | |
omni_semaphore | shutdownSemaphore (0) |
int | main (int argc, char *argv[]) |
void | Omniifr_Orb_shutdown (int signum) |
Signal handler, sets Orb::_shutdownRequested. | |
void | Omniifr_Orb_bumpTraceLevel (int signum) |
Signal handler, each call to this method 'bumps' up the trace level by 5, modulo 45. | |
void | Omniifr_Ifr_checkpoint (int signum) |
Signal handler, forces a checkpoint (saves IFR state to file). | |
Variables | |
CORBA::ORB_var | orb |
The global ORB. | |
bool | readonly = false |
Is the IFR to be readonly - set by options(). | |
Omniifr::Persist * | persist = NULL |
int | checkpointPeriodSec = 900 |
How often to checkpoint - set by options(). |
|
Definition at line 95 of file main.cc. References checkpointPeriodSec, Omniifr::daemon, Omniifr::Daemon::daemonize(), DB, IFELSE_OMNIORB4, Omniifr::Repository_impl::inst(), Omniifr_Ifr_checkpoint(), Omniifr_Orb_bumpTraceLevel(), Omniifr_Orb_shutdown(), orb, persist, readonly, Omniifr::Daemon::runningOk(), and shutdownSemaphore(). 00096 { 00097 Omniifr::Daemon daemon(argc,argv); 00098 00099 const char* action=""; // Use this variable to help report errors. 00100 try 00101 { 00102 action="initialising ORB"; 00103 orb=CORBA::ORB_init(argc,argv); 00104 00105 action="constructing Persist"; 00106 persist =new Omniifr::Persist(readonly? 0: checkpointPeriodSec); 00107 00108 #ifdef HAVE_GETOPT 00109 action="processing command line options"; 00110 options(argc,argv,daemon,*persist); 00111 #endif 00112 00113 action="daemonizing"; 00114 daemon.daemonize(); 00115 00116 00117 action="initialising Repository"; 00118 Omniifr::Repository_impl::inst().init( orb.in(), readonly, persist ); 00119 if(readonly) 00120 { 00121 action="destroying Persist"; 00122 delete persist; 00123 persist=NULL; 00124 } 00125 00126 #ifdef HAVE_SIGNAL_H 00127 SIGSET(SIGINT , ::Omniifr_Orb_shutdown); 00128 SIGSET(SIGTERM, ::Omniifr_Orb_shutdown); 00129 # ifdef SIGUSR1 00130 SIGSET(SIGUSR1, ::Omniifr_Orb_bumpTraceLevel); 00131 # endif 00132 # ifdef SIGUSR2 00133 SIGSET(SIGUSR2, ::Omniifr_Ifr_checkpoint); 00134 # endif 00135 # ifdef SIGPIPE 00136 SIGSET(SIGPIPE, SIG_IGN); // Ignore broken pipes 00137 # endif 00138 #endif 00139 00140 action="closing parent process"; 00141 daemon.runningOk(); 00142 00143 // Park the main thread. 00144 // Do this by waiting on a semaphore rather than calling ORB_run() - 00145 // this makes it safe for a signal to wake us up. 00146 action="running ORB"; 00147 cout<<action<<'.'<<endl; 00148 shutdownSemaphore.wait(); 00149 00150 // SIGTERM or whatever has triggered shutdown. 00151 DB(1,"Shutdown requested.") 00152 action="shutting down ORB"; 00153 orb->shutdown(1); // Synchronous shutdown 00154 action="destroying ORB"; 00155 orb->destroy(); // clean up 00156 if(persist) 00157 { 00158 action="destroying Persist"; 00159 delete persist; 00160 } 00161 return 0; 00162 00163 } 00164 catch(CORBA::SystemException& ex) 00165 { 00166 cerr<<"Failed while "<<action<<"." 00167 IFELSE_OMNIORB4(" "<<ex._name()<<" ("<<ex.NP_minorString()<<")",) <<endl; 00168 } 00169 catch(CORBA::Exception& ex) 00170 { 00171 cerr<<"Failed while "<<action<<"." IFELSE_OMNIORB4(" "<<ex._name(),) <<endl; 00172 } 00173 return 1; 00174 }
|
|
Signal handler, forces a checkpoint (saves IFR state to file).
Definition at line 194 of file main.cc. References Omniifr::Persist::checkpoint(), DB, persist, and readonly. Referenced by main(). 00195 { 00196 if(readonly) 00197 { 00198 DB(1,"Checkpoint request ignored: Interface Repository is read only.") 00199 } 00200 else 00201 { 00202 DB(1,"Checkpoint requested.") 00203 assert(persist!=NULL); 00204 persist->checkpoint(); 00205 } 00206 }
|
|
Signal handler, each call to this method 'bumps' up the trace level by 5, modulo 45.
Definition at line 188 of file main.cc. References DB. Referenced by main(). 00189 { 00190 omniORB::traceLevel=(omniORB::traceLevel+5)%45; 00191 DB(0,"TRACE LEVEL BUMPED TO "<<omniORB::traceLevel<<" BY SIGNAL "<<signum) 00192 }
|
|
Signal handler, sets Orb::_shutdownRequested. The parameter is ignored. This method may be used as a signal handler. Definition at line 182 of file main.cc. References shutdownSemaphore(). Referenced by main(). 00183 { 00184 // Wake up the main thread. 00185 shutdownSemaphore.post(); 00186 }
|
|
Referenced by main(), and Omniifr_Orb_shutdown(). |
|
How often to checkpoint - set by options().
Definition at line 45 of file main.cc. Referenced by main(). |
|
The global ORB.
Definition at line 42 of file main.cc. Referenced by Omniifr::Repository_impl::init(), and main(). |
|
Definition at line 44 of file main.cc. Referenced by Omniifr::Repository_impl::init(), main(), Omniifr_Ifr_checkpoint(), and Omniifr::Persist::WriteLock::WriteLock(). |
|
Is the IFR to be readonly - set by options().
Definition at line 43 of file main.cc. Referenced by Omniifr::Repository_impl::init(), main(), and Omniifr_Ifr_checkpoint(). |