Created UserInterface namespace, WebServerService -> UserInterfaceService.
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
|
||||
#include "RemoteServerService.hpp"
|
||||
|
||||
RemoteServerService::RemoteServerService(const Remote::Server::Server::endpoint_type& endpoint)
|
||||
: _server(endpoint)
|
||||
RemoteServerService::RemoteServerService(const Remote::Server::Server::endpoint_type& endpoint, boost::filesystem::path dbPath)
|
||||
: _server(endpoint, dbPath)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef REMOTE_SERVER_SERVICE_HPP
|
||||
#define REMOTE_SERVER_SERVICE_HPP
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include "Service.hpp"
|
||||
|
||||
@@ -10,7 +11,7 @@ class RemoteServerService : public Service
|
||||
{
|
||||
public:
|
||||
|
||||
RemoteServerService(const Remote::Server::Server::endpoint_type& endpoint);
|
||||
RemoteServerService(const Remote::Server::Server::endpoint_type& endpoint, boost::filesystem::path dbPath);
|
||||
|
||||
void start(void);
|
||||
void stop(void);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
#include <csignal>
|
||||
//#include <csignal>
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
@@ -7,15 +7,15 @@
|
||||
#include "ServiceManager.hpp"
|
||||
|
||||
ServiceManager::ServiceManager()
|
||||
/*: _signalSet(_ioService) */
|
||||
: _signalSet(_ioService)
|
||||
{
|
||||
/* _signalSet.add(SIGINT);
|
||||
_signalSet.add(SIGINT);
|
||||
_signalSet.add(SIGTERM);
|
||||
#if defined(SIGQUIT)
|
||||
_signalSet.add(SIGQUIT);
|
||||
#endif // defined(SIGQUIT)
|
||||
|
||||
_signalSet.add(SIGHUP);*/
|
||||
_signalSet.add(SIGHUP);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -27,15 +27,16 @@ ServiceManager::run()
|
||||
// Wait for events
|
||||
_ioService.run();
|
||||
|
||||
std::cout << "ServiceManager::run complete!" << std::endl;
|
||||
}
|
||||
|
||||
void
|
||||
ServiceManager::asyncWaitSignals(void)
|
||||
{
|
||||
/* _signalSet.async_wait(boost::bind(&ServiceManager::handleSignal,
|
||||
_signalSet.async_wait(boost::bind(&ServiceManager::handleSignal,
|
||||
this,
|
||||
boost::asio::placeholders::error,
|
||||
boost::asio::placeholders::signal_number));*/
|
||||
boost::asio::placeholders::signal_number));
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -31,7 +31,7 @@ class ServiceManager
|
||||
boost::asio::io_service _ioService;
|
||||
|
||||
// Listen for interesting signals
|
||||
// boost::asio::signal_set _signalSet;
|
||||
boost::asio::signal_set _signalSet;
|
||||
|
||||
std::set<Service::pointer> _services;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
||||
#include "UserInterfaceService.hpp"
|
||||
#include "ui/LmsApplication.hpp"
|
||||
|
||||
UserInterfaceService::UserInterfaceService( int argc, char* argv[], boost::filesystem::path dbPath)
|
||||
: _server(argv[0], "")
|
||||
{
|
||||
// TODO configure server using another way (config file?)
|
||||
_server.setServerConfiguration (argc, argv, WTHTTP_CONFIGURATION);
|
||||
|
||||
// bind entry point
|
||||
_server.addEntryPoint(Wt::Application, boost::bind(UserInterface::LmsApplication::create, _1, dbPath));
|
||||
}
|
||||
|
||||
void
|
||||
UserInterfaceService::start(void)
|
||||
{
|
||||
_server.start();
|
||||
std::cout << "UserInterfaceService::start -> Service started..." << std::endl;
|
||||
}
|
||||
|
||||
void
|
||||
UserInterfaceService::stop(void)
|
||||
{
|
||||
std::cout << "UserInterfaceService::stop -> stopping..." << std::endl;
|
||||
_server.stop();
|
||||
std::cout << "UserInterfaceService::stop -> stopped!" << std::endl;
|
||||
}
|
||||
|
||||
void
|
||||
UserInterfaceService::restart(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
#ifndef WEB_SERVER_SERVICE_HPP
|
||||
#define WEB_SERVER_SERVICE_HPP
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include <Wt/WServer>
|
||||
|
||||
#include "Service.hpp"
|
||||
|
||||
class WebServerService : public Service
|
||||
class UserInterfaceService : public Service
|
||||
{
|
||||
public:
|
||||
WebServerService( int argc, char* argv[]);
|
||||
UserInterfaceService( int argc, char* argv[], boost::filesystem::path dbPath);
|
||||
|
||||
void start(void);
|
||||
void stop(void);
|
||||
@@ -1,57 +0,0 @@
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
||||
#include "WebServerService.hpp"
|
||||
#include "ui/LmsApplication.hpp"
|
||||
|
||||
|
||||
static Wt::WApplication *createApplication(const Wt::WEnvironment& env)
|
||||
{
|
||||
/*
|
||||
* You could read information from the environment to decide whether
|
||||
* the user has permission to start a new application
|
||||
*/
|
||||
std::cout << "Creating new Application" << std::endl;
|
||||
return new LmsApplication(env);
|
||||
}
|
||||
|
||||
WebServerService::WebServerService( int argc, char* argv[])
|
||||
: _server(argv[0], "")
|
||||
{
|
||||
|
||||
std::cout << "Constructing server... argv[0] = '" << argv[0] << "' argc = " << argc << std::endl;
|
||||
|
||||
// TODO configure server
|
||||
_server.setServerConfiguration (argc, argv, WTHTTP_CONFIGURATION);
|
||||
|
||||
// bind entry point
|
||||
|
||||
_server.addEntryPoint(Wt::Application, createApplication);
|
||||
|
||||
std::cout << "WebServerService done!" << std::endl;
|
||||
}
|
||||
|
||||
void
|
||||
WebServerService::start(void)
|
||||
{
|
||||
std::cout << "Starting service..." << std::endl;
|
||||
|
||||
bool res = _server.start();
|
||||
std::cout << "_server.start returned " << std::boolalpha << res << std::endl;
|
||||
|
||||
std::cout << "Service started..." << std::endl;
|
||||
}
|
||||
|
||||
void
|
||||
WebServerService::stop(void)
|
||||
{
|
||||
_server.stop();
|
||||
}
|
||||
|
||||
void
|
||||
WebServerService::restart(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
+11
-31
@@ -1,26 +1,18 @@
|
||||
#include <memory>
|
||||
#include <Wt/WServer>
|
||||
#include <Wt/WIOService>
|
||||
#include <csignal>
|
||||
|
||||
#include "transcode/AvConvTranscoder.hpp"
|
||||
#include "av/Common.hpp"
|
||||
|
||||
#include "ServiceManager.hpp"
|
||||
#include "DatabaseRefreshService.hpp"
|
||||
#include "WebServerService.hpp"
|
||||
#include "UserInterfaceService.hpp"
|
||||
#include "RemoteServerService.hpp"
|
||||
|
||||
#include "ui/LmsApplication.hpp"
|
||||
|
||||
static Wt::WApplication *createApplication(const Wt::WEnvironment& env)
|
||||
{
|
||||
/*
|
||||
* You could read information from the environment to decide whether
|
||||
* the user has permission to start a new application
|
||||
*/
|
||||
std::cout << "Creating new Application" << std::endl;
|
||||
return new LmsApplication(env);
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
|
||||
@@ -28,32 +20,20 @@ int main(int argc, char* argv[])
|
||||
|
||||
try
|
||||
{
|
||||
// ServiceManager serviceManager;
|
||||
ServiceManager serviceManager;
|
||||
|
||||
// TODO Retreive the database path in some config file
|
||||
const boost::filesystem::path dbPath("test.db");
|
||||
|
||||
// lib init
|
||||
Av::AvInit();
|
||||
Transcode::AvConvTranscoder::init();
|
||||
|
||||
return Wt::WRun(argc, argv, createApplication);
|
||||
/* Wt::WServer server(argv[0], "");
|
||||
serviceManager.startService( std::make_shared<DatabaseRefreshService>( dbPath) );
|
||||
serviceManager.startService( std::make_shared<UserInterfaceService>(argc, argv, dbPath) );
|
||||
serviceManager.startService( std::make_shared<RemoteServerService>( Remote::Server::Server::endpoint_type(), dbPath) );
|
||||
|
||||
server.setServerConfiguration(argc, argv, WTHTTP_CONFIGURATION);
|
||||
server.addEntryPoint(Wt::Application, createApplication);
|
||||
if (server.start()) {
|
||||
int sig = Wt::WServer::waitForShutdown(argv[0]);
|
||||
std::cerr << "Shutdown (signal = " << sig << ")" << std::endl;
|
||||
server.stop();
|
||||
if (sig == SIGHUP)
|
||||
Wt::WServer::restart(argc, argv, environ);
|
||||
}*/
|
||||
// return 0;
|
||||
|
||||
|
||||
// serviceManager.startService( std::make_shared<DatabaseRefreshService>( "test.db" ) );
|
||||
// serviceManager.startService( std::make_shared<WebServerService>(argc, argv) );
|
||||
// serviceManager.startService( std::make_shared<RemoteServerService>( Remote::Server::Server::endpoint_type() ) );
|
||||
|
||||
// serviceManager.run();
|
||||
serviceManager.run();
|
||||
|
||||
res = EXIT_SUCCESS;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user