51 #if defined(HAVE_SIGNAL_H) && defined(HAVE_SIGSET) 53 # define SIGSET(sig,func) ::sigset(sig,func) 54 #elif defined(HAVE_SIGNAL_H) 56 # define SIGSET(sig,func) ::signal(sig,func) 60 # include <omniORB4/internal/orbOptions.h> 66 int main(
int argc,
char** argv)
74 int originalArgc =argc;
75 char** originalArgv =
new char*[originalArgc];
76 for(
int i=0; i<originalArgc; ++i)
77 originalArgv[i]=strdup(argv[i]);
81 omni::orbOptions::singleton().extractInitOptions(argc,argv);
93 const char* endPointNoListen =NULL;
95 const char* logDir =NULL;
96 const char* factoryName =
"EventChannelFactory";
100 while ((c =
getopt(argc,argv,
"O:a:p:l:P:N:dft:vVh")) != EOF)
107 case 'a': endPointNoListen=
optarg;
110 case 'p': port=atoi(
optarg);
113 cerr<<
"\nError: port must be a positive integer"<<endl;
125 case 'N': factoryName=
optarg;
128 case 'd': cerr<<
"Option '-d' is deprecated. Use '-f' instead."<<endl;
139 case 'v': verbose=
true;
146 default :
usage(argc,argv);
158 initialState=logfile.
parse();
160 if(port && port!=initialState->
child(
"ecf")->
attrLong(
"port"))
163 "Error: Option '-p "<<port<<
"' conflicts with value '"<<
164 initialState->
child(
"ecf")->
attrLong(
"port")<<
"'\n stored in" 166 " Either delete the file to clear the database, or do not use the" 167 " '-p' option."<<endl;
170 if(endPointNoListen &&
string(endPointNoListen)!=
174 "Error: Option '-a "<<endPointNoListen<<
"' conflicts with value '"<<
177 " Either delete the file to clear the database, or do not use the" 178 " '-a' option."<<endl;
186 "Error: backup file '" << logfile.
backupFilename() <<
"' exists.\n" 188 " to recover the server's state, or delete it to create a new\n" 189 " database file." << endl;
195 initialState=logfile.
bootstrap(port?port:11169,endPointNoListen);
198 string endPoint2=initialState->
child(
"ecf")->
attrString(
"endPointNoListen");
208 sprintf(endPoint,
"giop:::%d",port);
209 if(endPoint2.empty())
211 const char* opts[][2] ={ {
"endPoint",endPoint}, {0,0} };
212 Orb::inst().
_orb=CORBA::ORB_init(originalArgc,originalArgv,
"omniORB4",opts);
216 const char* opts[][2] ={
217 {
"endPoint",endPoint},
218 {
"endPointNoListen",endPoint2.c_str()},
220 Orb::inst().
_orb=CORBA::ORB_init(originalArgc,originalArgv,
"omniORB4",opts);
224 argv[1] = strdup(
"-ORBpoa_iiop_port");
225 argv[2] =
new char[32 + 1];
226 sprintf(argv[2],
"%d", port);
231 PortableServer::POAManager_var pman;
249 omniEvents::EventChannelFactory_var factory( logfile.
factory()->_this() );
260 DB(1,
"Starting omniEvents on port "<<port)
261 if(!endPoint2.empty())
262 DB(1,
"Alternate endPoint "<<endPoint2.c_str())
263 CORBA::String_var iorstr =
276 SIGSET(SIGPIPE, SIG_IGN);
287 DB(1,
"Shutdown requested.")
295 catch (CORBA::SystemException& ex) {
298 catch (CORBA::Exception& ex) {
299 DB(0,
"CORBA exception: "<<ex._name())
319 omniORB::traceLevel=(omniORB::traceLevel+5)%45;
320 DB(0,
"TRACE LEVEL BUMPED TO "<<omniORB::traceLevel<<
" BY SIGNAL "<<signum)
PersistNode * child(const string &key) const
void run()
Parks the main thread, but also picks up (and ignores) responses from orphan requests.
#define NP_MINORSTRING(systemException)
void pidfile(const char *val)
Set _pidfile.
void foreground(bool val)
Set _foreground.
virtual void runWorker()
Kicks off the worker thread that periodically checkpoints the persistency logfile.
virtual PersistNode * parse()
Creates an initialState from the logfile.
string attrString(const string &key, const string &fallback="") const
DaemonImpl daemon
Singleton - only at file scope.
PortableServer::POA_var _RootPOA
int getopt(int argc, char *argv[], const char *optionS)
int bindName2Object(CosNaming::NamingContext_ptr namingContext, const CosNaming::Name &name, CORBA::Object_ptr obj)
Binds CosNaming::Name to object in the naming service.
void OmniEvents_Orb_shutdown(int signum)
Signal handler, sets Orb::_shutdownRequested.
void usage(int argc, char **argv)
const char * backupFilename() const
void shutdown(int)
Sets _shutdownRequested.
void incarnateFactory(PersistNode *initialState)
Constructs the EventChannelFactory from the information in the initialState parameter.
void OmniEvents_Orb_bumpTraceLevel(int signum)
Signal handler, each call to this method 'bumps' up the trace level by 5, modulo 45.
Interface class that contains various methods for running omniEvents as a background task...
CosNaming::Name str2name(const char *namestr)
Converts stringified name to naming service name.
bool fileExists(const char *filename) const
void resolveInitialReferences()
_orb must already have been initialized before this method is called.
long attrLong(const string &key, long fallback=0) const
void daemonize()
Redirects output streams to tracefile.
const char * version()
Returns the constant version ID and copyright string.
void runningOk()
Called to signal that all startup operations have completed OK.
void insertArgs(int &argc, char **&argv, int idx, int nargs)
Utility function, used to manipulate argv when using omniORB3.
const char * activeFilename() const
PersistNode * bootstrap(int port, const char *endPointNoListen)
Creates an initialState from its arguments.
PortableServer::POA_var _omniINSPOA
int main(int argc, char **argv)
The main process entry point.
EventChannelFactory_i * factory()
accessor method
void tracefile(const char *val)
Set _tracefile.