27 , configFileName_( configFileName )
29 , plugin_monitor_( 0 )
42 std::vector<Network*>::iterator it;
43 for(it = networks_.begin(); it != networks_.end(); ++it)
50 delete plugin_monitor_;
66 fprintf(stderr,
"dazeus::DaZeus::autoConnect() called: looking for networks to connect to\n");
68 std::vector<Network*>::iterator it;
69 for(it = networks_.begin(); it != networks_.end(); ++it)
75 fprintf(stderr,
"Connecting to %s (autoconnect is enabled)\n",
Network::toString(n).c_str());
82 fprintf(stderr,
"Not connecting to %s, autoconnect is disabled.\n",
Network::toString(n).c_str());
90 return configFileName_;
98 return config_->isRead();
111 fprintf(stderr,
"Database configuration is absent, cannot continue.\n");
116 if( !database_->open() )
118 fprintf(stderr,
"Could not connect to database: %s\n", database_->lastError().c_str());
140 assert(plugins_ != 0);
156 assert( configFileName_.length() != 0 );
170 std::cerr <<
"Failed to read configuration: " << e.what() << std::endl;
174 const std::vector<NetworkConfig*> &networks = config_->getNetworks();
176 if(!connectDatabase()) {
184 plugins_ =
new PluginComm( database_, config_,
this );
185 plugin_monitor_ =
new PluginMonitor(config_->getPluginSocket(),
186 config_->getGlobalConfig()->plugindirectory,
187 config_->getPlugins(),
188 config_->getNetworks());
190 std::vector<NetworkConfig*>::const_iterator it;
191 for(it = networks.begin(); it != networks.end(); ++it)
201 networks_.push_back( net );
206 std::stringstream numInitsStr;
207 numInitsStr << database_->property(
"dazeus.numinits");
209 numInitsStr >> numInits;
213 numInitsStr.str(
""); numInitsStr.clear();
214 numInitsStr << numInits;
215 database_->setProperty(
"dazeus.numinits", numInitsStr.str());
216 const char *suffix =
"th";
217 if(numInits%100 == 11 ) ;
218 else if(numInits%100 == 12) ;
219 else if(numInits%100 == 13) ;
220 else if(numInits%10 == 1) suffix =
"st";
221 else if(numInits%10 == 2) suffix =
"nd";
222 else if(numInits%10 == 3) suffix =
"rd";
223 printf(
"Initialising DaZeus for the %d%s time!\n", numInits, suffix);
229 plugin_monitor_->sigchild();
241 plugin_monitor_->runOnce();
249 plugins_->run(plugin_monitor_->shouldRun() ? 1 : 30);
254 configFileName_ = filename;