Fixed server file erroe

This commit is contained in:
Johannes Wendel
2019-10-09 21:55:07 +02:00
parent e086d79da3
commit 5e961d93c3
3 changed files with 20 additions and 12 deletions

View File

@@ -181,9 +181,11 @@ HTTPServer* FlippRServer::build_output_server()
{
unsigned short port = (unsigned short) config().getInt("FlippRServer.port", this->output_port);
output_socket_file = Poco::File(this->get_runtime_dir() + OUTPUT_SOCKET_NAME);
Poco::File socket_file(this->get_runtime_dir() + OUTPUT_SOCKET_NAME);
if (socket_file.exists())
socket_file.remove();
SocketAddress address(SocketAddress::UNIX_LOCAL, output_socket_file.path());
SocketAddress address(SocketAddress::UNIX_LOCAL, socket_file.path());
ServerSocket server_socket(address);
return new HTTPServer(new OutputRequestHandlerFactory(this->output_driver), server_socket, new HTTPServerParams);
@@ -193,9 +195,15 @@ TCPServer* FlippRServer::build_input_server()
{
unsigned short port = (unsigned short) config().getInt("FlippRServer.port", this->input_port);
input_socket_file = Poco::File(this->get_runtime_dir() + INPUT_SOCKET_NAME);
Poco::File socket_file(this->get_runtime_dir() + INPUT_SOCKET_NAME);
if (socket_file.exists())
{
socket_file.remove();
logger().information("Seems that server is already running. Make sure that only one instance of server is running.");
}
SocketAddress address(SocketAddress::UNIX_LOCAL, input_socket_file.path());
SocketAddress address(SocketAddress::UNIX_LOCAL, socket_file.path());
ServerSocket server_socket(address);
return new TCPServer(new input::InputSocketHandlerFactory(this->input_driver), server_socket);
@@ -261,8 +269,8 @@ void FlippRServer::handle_help(const std::string& name, const std::string& value
std::string FlippRServer::get_runtime_dir()
{
return DEFAULT_RUNTIME_DIR;
//return std::getenv("XDG_RUNTIME_DIR") ? std::getenv("XDG_RUNTIME_DIR") : DEFAULT_RUNTIME_DIR;
//return DEFAULT_RUNTIME_DIR;
return std::getenv("XDG_RUNTIME_DIR") ? std::string(std::getenv("XDG_RUNTIME_DIR")) + "/" : DEFAULT_RUNTIME_DIR;
}
}