Exemple #1
0
  int main(const std::vector<std::string>& args)
  {
    ScopedLogMessage msg(" main() ", "start", "end");
 
    if(m_helpRequested)
      {
	displayHelp();
      }
    else
      {
	CommandDispatcher	commandDispatcher(msg);
 
	unsigned short port = (unsigned short) config().getInt("MyTCPServer.port", 9923);
	Poco::Net::ServerSocket svs(port);
	Poco::Net::TCPServer srv(new TCPConnectionFactory(msg, commandDispatcher),
				 svs, new Poco::Net::TCPServerParams);
	srv.start();
 
	// wait for CTRL-C or kill
	waitForTerminationRequest();
 
	srv.stop();
      }
    return Poco::Util::Application::EXIT_OK;
  }
	int main(const std::vector<std::string>& args)
	{
		if (_helpRequested)
		{
			displayHelp();
		}
		else
		{
			// get parameters from configuration file
			unsigned short port = (unsigned short)config().getInt("TimeServer.port", 9911);
			std::string format(config().getString("TimeServer.format", Poco::DateTimeFormat::ISO8601_FORMAT));

			// set-up a server socket
			Poco::Net::ServerSocket svs(port);
			// set-up a TCPServer instance
			Poco::Net::TCPServer srv(new TimeServerConnectionFactory(format), svs);
			// start the TCPServer
			srv.start();

			// start push thread
			Poco::Thread thread;
			PushRunnable runnable;
			thread.start(runnable);

			// wait for CTRL-C or kill
			waitForTerminationRequest();
			// Stop the TCPServer
			srv.stop();
		}
		return Application::EXIT_OK;
	}
	int main(const std::vector<std::string>&)
	{
    unsigned short port = (unsigned short) config().getInt("HttpRouter.port", 9443);

    std::cout << port << std::endl;

    Poco::Net::SecureServerSocket svs(port);

    HttpRouter* router = new HttpRouter();

    router->AddRoute("/foo", GetHandler, "GET");
    router->AddRoute("/foo/bar", OtherGetHandler, "GET");
    router->AddRoute("/foo", PostHandler, "POST");
    router->AddRoute("/bar", HandlerClass(), "GET");
    router->AddRoute("/", DefaultRequestHandler);

    auto params = new Poco::Net::HTTPServerParams();

    Poco::Net::HTTPServer srv(router, svs, params);
    srv.start();
    waitForTerminationRequest();
    srv.stop();

    return Poco::Util::Application::EXIT_OK;
  }
Exemple #4
0
int BeeServer::main(const std::vector<std::string>& args)
{
		
	if (_serverState == SERVER_IDLE)
	{
		//create shared memory if start with non params
		readMemory();
		_serverFlag = true;
		setServerState(SERVER_RUNNING);
		writeMemory(_serverState);
		ServerArgv* exRun  = new ServerArgv(*this);
		_exThread.start(*exRun);

		//BeeTask* pTask = new BeeTask();
		//string rule = Application::instance().config().getString("rule");
		//pTask->setRule(rule);
		
		//TaskManager tm;
		//tm.start(pTask);
		task();
		waitForTerminationRequest();
		//tm.cancelAll();
		//tm.joinAll();

	}
	return Application::EXIT_OK;
}
int MyApp::main(const ArgVec &args)
{
    std::ignore = args;

    waitForTerminationRequest();

    task_manager.cancelAll();
    task_manager.joinAll();

    return Poco::Util::Application::EXIT_OK;
}
Exemple #6
0
int HttpServer<ServerContext, RequestFactory>::main(const std::vector<std::string>& args)
{
  Poco::Net::ServerSocket server_socket(config().getInt("Service.port", port_));
  Poco::Net::HTTPServer http_server(
    new RequestFactory(context_),
    server_socket,
    new Poco::Net::HTTPServerParams);
  http_server.start();
  waitForTerminationRequest();
  http_server.stop();
  return Poco::Util::Application::EXIT_OK;
}
int MomentHTTPServer::main(const std::vector<std::string> &)
{
    if(http_port == -1 || admin_http_port == -1)
        return Application::EXIT_NOHOST; // this error is most suitable

    HTTPServer * http_server = new HTTPServer(new HttpHandlerFactory, ServerSocket(http_port), new HTTPServerParams);
    HTTPServer * admin_http_server = new HTTPServer(new AdminHttpHandlerFactory, ServerSocket(admin_http_port), new HTTPServerParams);

    http_server->start();
    admin_http_server->start();

	waitForTerminationRequest();  // wait for CTRL-C or kill

    http_server->stop();
    admin_http_server->stop();

	return Application::EXIT_OK;
}
int RestServer::main(const vector<string>& args)
{
    if (!_helpRequested)
    {
        unsigned short port = (unsigned short)config().getInt("RestServer.port", 9980);
        std::string format(config().getString("RestServer.format",
                           DateTimeFormat::SORTABLE_FORMAT));


        ServerSocket serverSocket(port);
        HTTPServer server(new RestRequestRouter(), serverSocket,
                          new HTTPServerParams);
        server.start();
        logger().information("Welcome to PatternRester, the server is running in port 9980.");
        waitForTerminationRequest();
        server.stop();
    }
    return Application::EXIT_OK;
}
    int main(const std::vector<std::string>& args)
    {
        if (_helpRequested)
        {
            displayHelp();
        }
        else
        {
        // get parameters from configuration file
//             unsigned short port = (unsigned short) config().getInt("EchoServer.port", 9977);
            
            Omm::Av::HttpFileServer fileServer;
            fileServer.start();
            std::clog << "HttpFileServerTest::main() file server started on port: " << fileServer.getPort() << std::endl;
            
//             fileServer.registerFile("foo", "/home/jb/tmp/hal.log");
            std::clog << "HttpFileServerTest::main() waiting for termination request" << std::endl;
            waitForTerminationRequest();
        }
        return Application::EXIT_OK;
    }
Exemple #10
0
int RemoteProvider::main(const std::vector<std::string>& args) {

	std::cout << "-------------------" << std::endl;
	std::cout << "HAL Observer Starts" << std::endl;
	std::cout << "-------------------" << std::endl;

	std::cout << std::endl;

	{

		{
			RemoteJsonServer::Ptr jsonSrv = new RemoteJsonServer();
			{
				TBS::Services::JsonServerChannel ch(8080);

				HAL::Remote::Json::Server server(ch);
				{
					TBS::Services::IServer::Ptr srv = server.createMovement(jsonSrv);
					server.start();
					waitForTerminationRequest();
					server.stop();
				}

			}

		}
	}

	std::cout << std::endl;
	std::cout << std::endl;

	std::cout << "------------------" << std::endl;
	std::cout << "HAL Observer Stops" << std::endl;
	std::cout << "------------------" << std::endl;

	return EXIT_OK;
}
Exemple #11
0
int ChatServer::main(const std::vector<std::string>& args)
{
    unsigned short port = 10000;
    Poco::Net::ServerSocket svs(port);
    Poco::Net::SocketReactor reactor;
    
    Poco::Net::ParallelSocketAcceptor<ChatServerHandler, Poco::Net::SocketReactor> acceptors(svs, reactor, 4);
    
    Poco::Thread reactorThread, commandThread;
    reactorThread.start(reactor);
    
//    Poco::NotificationQueue queue;
//    CommandExecutor commandExecutor(queue);


    commandThread.start(commandExecutor);
    waitForTerminationRequest();
    queue.wakeUpAll();
    reactor.stop();
    reactorThread.join();
    commandThread.join();
    
    return Application::EXIT_OK;
}
Exemple #12
0
int AuthServer::main(const std::vector<std::string>& args)
{
    Poco::Logger::root().information("TRILOGY-CORE");
    Poco::Logger::root().information("AUTHSERVER");
    std::cout << vers_major << "." << vers_minor << "." << patch << std::endl;
    //on charge la configuration du serveur
    if (!sConfigMgr->loadInitial(config))
    {
        return EXIT_CONFIG;
    }

    _params = new Poco::Net::TCPServerParams;
    _params->setMaxThreads(sConfigMgr->GetIntDefault("authserver.maxThreadNumber", 4));
    _params->setMaxQueued(sConfigMgr->GetIntDefault("authserver.maxConnectionQueued", 100));
    _params->setThreadIdleTime(100);

    //Create a server socket, does bind + listen
    Poco::Net::ServerSocket svs(sConfigMgr->GetIntDefault("authServerPort",5555));
    //on crée le serveur de connexion
    _server = new Poco::Net::TCPServer(new AuthSessionFactory(), svs, _params);
    //on lance le serveur de connexion
    _server->start();
    Poco::Logger::root().information("Serveur de connexion lancé sur le port :");
    Poco::Logger::root().information(Poco::NumberFormatter::format(_server->port()));
    waitForTerminationRequest();  // wait for CTRL-C or kill
    Poco::Logger::root().information("Fermeture du serveur...");
    Poco::Logger::root().information(Poco::NumberFormatter::format(_server->totalConnections()));
    //on arrete le serveur de connexion
    _server->stop();
    //on regarde si il reste des connexions active
    if (_server->currentConnections() != 0)
    {
        svs.close();
    }
    return EXIT_OK;
}
Exemple #13
0
	int HALService::main(const std::vector<std::string>& args) {
		if (help) {
			return EXIT_OK;
		}

		TBS::initLogs("hal", 4);

		std::cout << "-----------" << std::endl;
		std::cout << "HAL Service json" << std::endl;
		std::cout << "-----------" << std::endl;

		std::cout << "use BioRadar: " << (configuration.useBioRadar ? 1 : 0) << std::endl;
		std::cout << "use Manipulator: " << (configuration.useManipulator ? 1 : 0) << " port1: " << configuration.manipulatorJoint1Port << " port2: " << configuration.manipulatorJoint2Port << std::endl;
		std::cout << "-----------" << std::endl;


		std::cout << std::endl;

		{
			MBot::IHALFactory::Ptr f;

			if (virtualMode) {
				throw Poco::Exception("Cannot run virtual mode - not implemented");
				//f = new MBot::VirtualHALFactory();
			} else {
				f = new MBot::HALFactory(configuration.manipulatorJoint1Port, configuration.manipulatorJoint2Port);
			}

			TBS::Services::JsonServerParams bp(HAL::API::Communication::BioRadarPort);
			HAL::API::BioRadar::Json::Server::Ptr bioRadarSrv = HAL::API::BioRadar::Json::Server::createJsonServer(bp);

			TBS::Services::JsonServerParams cp(HAL::API::Communication::CameraPort);
			HAL::API::Camera::Json::Server::Ptr cameraSrv = HAL::API::Camera::Json::Server::createJsonServer(cp);

			TBS::Services::JsonServerParams ma(HAL::API::Communication::ManipulatorPort);
			HAL::API::Manipulator::Json::Server::Ptr manipSrv = HAL::API::Manipulator::Json::Server::createJsonServer(ma);
			{

				TBS::Services::IServer::Ptr camera = cameraSrv->createCamera(f->createCamera());

				TBS::Services::IServer::Ptr bioRadar;

				if (configuration.useBioRadar) {
					bioRadar = bioRadarSrv->createBioRadar(f->createBioRadar());
				}

				TBS::Services::IServer::Ptr manip;
				if (configuration.useManipulator) {
					manip = manipSrv->createManipulator(f->createManipulator());
				}
				cameraSrv->start();

				if (bioRadar) {
					bioRadarSrv->start();
				}
				if (manip) {
					manipSrv->start();
				}

				waitForTerminationRequest();

				cameraSrv->stop();

				if (bioRadar) {
					bioRadarSrv->stop();
				}
				if (manip) {
					manipSrv->stop();
				}
			}
		}

		std::cout << std::endl;
		std::cout << std::endl;

		std::cout << "-----------" << std::endl;
		std::cout << "HAL Service finished" << std::endl;
		std::cout << "-----------" << std::endl;

		return EXIT_OK;
	}