Fixed server file erroe
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ private:
|
||||
Poco::Net::TCPServer* build_input_server();
|
||||
|
||||
private:
|
||||
const char * DEFAULT_RUNTIME_DIR = "/tmp/flippR_driver-runtime/";
|
||||
const char * DEFAULT_RUNTIME_DIR = "/tmp/";
|
||||
const char * INPUT_SOCKET_NAME = "S.flippR_driver.in";
|
||||
const char * OUTPUT_SOCKET_NAME = "S.flippR_driver.out";
|
||||
const std::vector<std::string> REQUIRED_CONFIG_KEYS = {"display-config", "input-config", "lamp-config",
|
||||
|
||||
Reference in New Issue
Block a user