Revision: 41775
http://brlcad.svn.sourceforge.net/brlcad/?rev=41775&view=rev
Author: davidloman
Date: 2010-12-22 15:21:24 +0000 (Wed, 22 Dec 2010)
Log Message:
-----------
Clean up boot logic for both server and client. Mandate the presence of a
.config file (for now)
Modified Paths:
--------------
rt^3/trunk/src/GS/geoclient.cxx
rt^3/trunk/src/GS/geoserv.cxx
Modified: rt^3/trunk/src/GS/geoclient.cxx
===================================================================
--- rt^3/trunk/src/GS/geoclient.cxx 2010-12-22 15:20:39 UTC (rev 41774)
+++ rt^3/trunk/src/GS/geoclient.cxx 2010-12-22 15:21:24 UTC (rev 41775)
@@ -24,11 +24,51 @@
*/
#include "GSClient.h"
+#include "libutility.h"
+#include <QtCore/QString>
+#include <QtCore/QUuid>
+int gsExit(int code)
+{
+ Logger* log = Logger::getInstance();
+ log->logBANNER("geoclient", "GSClient is Shutting Down...");
+
+ JobManager::getInstance()->shutdown(true);
+
+ log->logINFO("geoclient", "Exiting.");
+ usleep(1000); /* Yeild main thread, let other threads finish unlocking
*/
+ exit(code);
+}
+
int
main(int argc, char* argv[])
{
- GSClient gsClient("TestingLocalNodeName");
+ std::cout << std::endl << std::endl;
+
+ Logger::getInstance();
+ JobManager::getInstance()->startup();
+
+ Logger* log = Logger::getInstance();
+ log->logBANNER("geoclient", "GSClient Config Loader");
+
+ Config* c = Config::getInstance();
+
+ /* Load configs from File */
+ bool goodLoad = c->loadFile("geoclient.config", true);
+
+ if ( ! goodLoad) {
+ log->logERROR("geoclient","Failed to properly Load config File.
Exiting.");
+ gsExit(1);
+ }
+
+ /* Check for a local node name. This is imperative to be set. */
+ QString localNodeName = c->getConfigValue("LocalNodeName");
+ if (localNodeName.length() == 0) {
+ log->logERROR("geoclient", "Config File does not contain a
'LocalNodeName' parameter");
+ gsExit(1);
+ }
+
+ GSClient gsClient(localNodeName);
return gsClient.run();
}
Modified: rt^3/trunk/src/GS/geoserv.cxx
===================================================================
--- rt^3/trunk/src/GS/geoserv.cxx 2010-12-22 15:20:39 UTC (rev 41774)
+++ rt^3/trunk/src/GS/geoserv.cxx 2010-12-22 15:21:24 UTC (rev 41775)
@@ -58,41 +58,44 @@
Config* c = Config::getInstance();
- //TODO Configure system loads stuff here, could be prettier
- if (c->loadFile("geoserv.config", true) == false) {
+ /* Load configs from File */
+ bool goodLoad = c->loadFile("geoserv.config", true);
+
+ if ( ! goodLoad) {
log->logERROR("geoserv","Failed to properly Load config File.
Exiting.");
gsExit(1);
}
- QString localNodename = c->getConfigValue("LocalNodeName");
- if (localNodename == "") {
- localNodename = "DefaultGSNodename";
- }
+ /* Check for a local node name. This is imperative to be set. */
+ QString localNodeName = c->getConfigValue("LocalNodeName");
+ if (localNodeName.length() == 0) {
+ log->logERROR("geoserv", "Config File does not contain a
'LocalNodeName' parameter");
+ gsExit(1);
+ }
- log->logBANNER("geoserv", "Booting GeometryService: " + localNodename);
+ log->logBANNER("geoserv", "Booting GeometryService: " + localNodeName);
- QString sport = c->getConfigValue("ListenPort");
- if (sport == NULL){
+ QString sPort = c->getConfigValue("ListenPort");
+ if (sPort == NULL){
log->logERROR("geoserv", "Config File does not contain a 'ListenPort'
parameter");
gsExit(1);
}
- if (sport.length() <= 0){
+ if (sPort.length() <= 0){
log->logERROR("geoserv", "Config File contains a 'ListenPort' key,
however the value length was <= 0.");
gsExit(1);
}
bool ok;
- quint16 port = sport.toUShort(&ok, 10);
+ quint16 port = sPort.toUShort(&ok, 10);
if (!ok){
log->logERROR("geoserv", "Config File contains a 'ListenPort' key,
however the value failed to parse to a valid number.");
return 1;
}
- bool daemon = false;
- GeometryService* gs = new GeometryService(localNodename, port);
+ GeometryService gs (localNodeName, port);
- //DataManager elements.
+ /* DataManager elements. */
QString useFileRepo = c->getConfigValue("UseFileRepo").toLower();
if (useFileRepo == "yes" || useFileRepo == "true"){
QString fileRepoPath = c->getConfigValue("FileRepoPath").toLower();
@@ -104,16 +107,12 @@
log->logINFO("geoserv", "FileDataSouce being used.");
FileDataSource* fds = new FileDataSource(fileRepoPath);
- gs->getDataManager()->addDataSource(fds);
+ gs.getDataManager()->addDataSource(fds);
}
- if (daemon){
- gs->start(); //will exit
- } else {
- gs->run(); //blocks
- }
+ gs.run(); /* blocks */
+
log->logINFO("geoserv", "Exiting...");
- delete gs;
return 0;
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Forrester recently released a report on the Return on Investment (ROI) of
Google Apps. They found a 300% ROI, 38%-56% cost savings, and break-even
within 7 months. Over 3 million businesses have gone Google with Google Apps:
an online email calendar, and document program that's accessible from your
browser. Read the Forrester report: http://p.sf.net/sfu/googleapps-sfnew
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits