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>
66int 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);
155 if(logfile.fileExists(logfile.activeFilename()))
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"
165 " database file '"<<logfile.activeFilename()<<
"'.\n"
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 '"<<
176 " stored in database file '"<<logfile.activeFilename()<<
"'.\n"
177 " Either delete the file to clear the database, or do not use the"
178 " '-a' option."<<endl;
182 else if(logfile.fileExists(logfile.backupFilename()))
186 "Error: backup file '" << logfile.backupFilename() <<
"' exists.\n"
187 " Rename it to '" << logfile.activeFilename() <<
"'\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);
227 Orb::inst()._orb=CORBA::ORB_init(argc,argv);
229 Orb::inst().resolveInitialReferences();
231 PortableServer::POAManager_var pman;
232 pman=Orb::inst()._RootPOA->the_POAManager();
234 pman=Orb::inst()._omniINSPOA->the_POAManager();
242 logfile.incarnateFactory(initialState);
249 omniEvents::EventChannelFactory_var factory( logfile.factory()->_this() );
251 Orb::inst()._NameService.in(),
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 =
264 Orb::inst()._orb->object_to_string(factory.in());
276 SIGSET(SIGPIPE, SIG_IGN);
287 DB(1,
"Shutdown requested.")
288 Orb::inst()._orb->shutdown(1);
289 Orb::inst()._orb->destroy();
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)
int bindName2Object(CosNaming::NamingContext_ptr namingContext, const CosNaming::Name &name, CORBA::Object_ptr obj)
Binds CosNaming::Name to object in the naming service.
CosNaming::Name str2name(const char *namestr)
Converts stringified name to naming service name.
int main(int argc, char **argv)
The main process entry point.
void OmniEvents_Orb_shutdown(int signum)
Signal handler, sets Orb::_shutdownRequested.
void OmniEvents_Orb_bumpTraceLevel(int signum)
Signal handler, each call to this method 'bumps' up the trace level by 5, modulo 45.
int getopt(int argc, char *argv[], const char *optionS)
#define NP_MINORSTRING(systemException)
static void usage(int argc, char **argv)
void insertArgs(int &argc, char **&argv, int idx, int nargs)
Utility function, used to manipulate argv when using omniORB3.
DaemonImpl daemon
Singleton - only at file scope.
const char * version()
Returns the constant version ID and copyright string.
Interface class that contains various methods for running omniEvents as a background task.
void runningOk()
Called to signal that all startup operations have completed OK.
void foreground(bool val)
Set _foreground.
void tracefile(const char *val)
Set _tracefile.
void pidfile(const char *val)
Set _pidfile.
void daemonize()
Puts the current process into the background.
Singleton class that owns the ORB and various initial references.
void shutdown(int)
Sets _shutdownRequested.
string attrString(const string &key, const string &fallback="") const
long attrLong(const string &key, long fallback=0) const
PersistNode * child(const string &key) const