WIP. Adding config file handling. UserInterface settings implemented

This commit is contained in:
emeric
2014-08-21 15:24:23 +02:00
parent 2f376fbc7a
commit e8b2412cd6
16 changed files with 211 additions and 23 deletions
+29 -12
View File
@@ -1,19 +1,14 @@
#include <memory>
#include <Wt/WServer>
#include <Wt/WIOService>
#include <csignal>
#include <boost/filesystem.hpp>
#include "config/ConfigReader.hpp"
#include "transcode/AvConvTranscoder.hpp"
#include "av/Common.hpp"
#include "database/DatabaseHandler.hpp"
#include "service/ServiceManager.hpp"
#include "service/DatabaseUpdateService.hpp"
#include "service/UserInterfaceService.hpp"
#include "service/RemoteServerService.hpp"
#include "ui/LmsApplication.hpp"
int main(int argc, char* argv[])
{
@@ -21,7 +16,26 @@ int main(int argc, char* argv[])
try
{
ServiceManager& serviceManager = ServiceManager::instance();
// TODO generate a nice command line help with args
// Open configuration file
boost::filesystem::path configFile("/etc/lms.conf");
if (argc > 1)
configFile = boost::filesystem::path(argv[1]);
if ( !boost::filesystem::exists(configFile)
|| !boost::filesystem::is_regular(configFile))
{
std::cerr << "Cannot open config file '" << configFile << "'" << std::endl;
return EXIT_FAILURE;
}
ConfigReader configReader(configFile);
Service::UserInterfaceService::Config uiConfig;
configReader.getUserInterfaceConfig(uiConfig);
Service::ServiceManager& serviceManager = Service::ServiceManager::instance();
// TODO Retreive the database path in some config file
const boost::filesystem::path dbPath("test.db");
@@ -34,9 +48,9 @@ int main(int argc, char* argv[])
std::cout << "Starting services..." << std::endl;
serviceManager.startService( std::make_shared<DatabaseUpdateService>( dbPath) );
serviceManager.startService( std::make_shared<RemoteServerService>( remoteListenEndpoint, dbPath) );
serviceManager.startService( std::make_shared<UserInterfaceService>(argc, argv, dbPath) );
serviceManager.startService( std::make_shared<Service::DatabaseUpdateService>( dbPath) );
serviceManager.startService( std::make_shared<Service::RemoteServerService>( remoteListenEndpoint, dbPath) );
serviceManager.startService( std::make_shared<Service::UserInterfaceService>(boost::filesystem::path(argv[0]), uiConfig));
std::cout << "Running..." << std::endl;
@@ -45,10 +59,13 @@ int main(int argc, char* argv[])
res = EXIT_SUCCESS;
}
catch( libconfig::ParseException& e)
{
std::cerr << "Caught libconfig::ParseException! error='" << e.getError() << "', file = '" << e.getFile() << "', line = " << e.getLine() << std::endl;
}
catch( Wt::WServer::Exception& e)
{
std::cerr << "Caught WServer::Exception: " << e.what() << std::endl;
}
catch( std::exception& e)
{