Deleting socket files now
This commit is contained in:
@@ -98,6 +98,14 @@ void FlippRServer::uninitialize()
|
|||||||
this->output_server->stop();
|
this->output_server->stop();
|
||||||
|
|
||||||
ServerApplication::uninitialize();
|
ServerApplication::uninitialize();
|
||||||
|
|
||||||
|
Poco::File socket_file(this->output_socket_file_path);
|
||||||
|
if (socket_file.exists())
|
||||||
|
socket_file.remove();
|
||||||
|
|
||||||
|
Poco::File input_socket_file(this->input_socket_file_path);
|
||||||
|
if (input_socket_file.exists())
|
||||||
|
input_socket_file.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -171,7 +179,7 @@ int FlippRServer::main(const std::vector<std::string>& args)
|
|||||||
{
|
{
|
||||||
if(!help_requested)
|
if(!help_requested)
|
||||||
{
|
{
|
||||||
logger().information("Server running!");
|
logger().information(FGRN("Server running!"));
|
||||||
waitForTerminationRequest();
|
waitForTerminationRequest();
|
||||||
}
|
}
|
||||||
return Application::EXIT_OK;
|
return Application::EXIT_OK;
|
||||||
@@ -182,7 +190,8 @@ HTTPServer* FlippRServer::build_output_server()
|
|||||||
{
|
{
|
||||||
unsigned short port = (unsigned short) config().getInt("FlippRServer.port", this->output_port);
|
unsigned short port = (unsigned short) config().getInt("FlippRServer.port", this->output_port);
|
||||||
|
|
||||||
Poco::File socket_file(this->get_runtime_dir() + OUTPUT_SOCKET_NAME);
|
this->output_socket_file_path = this->get_runtime_dir() + OUTPUT_SOCKET_NAME;
|
||||||
|
Poco::File socket_file(output_socket_file_path);
|
||||||
if (socket_file.exists())
|
if (socket_file.exists())
|
||||||
socket_file.remove();
|
socket_file.remove();
|
||||||
|
|
||||||
@@ -196,11 +205,12 @@ TCPServer* FlippRServer::build_input_server()
|
|||||||
{
|
{
|
||||||
unsigned short port = (unsigned short) config().getInt("FlippRServer.port", this->input_port);
|
unsigned short port = (unsigned short) config().getInt("FlippRServer.port", this->input_port);
|
||||||
|
|
||||||
Poco::File socket_file(this->get_runtime_dir() + INPUT_SOCKET_NAME);
|
this->input_socket_file_path = this->get_runtime_dir() + INPUT_SOCKET_NAME;
|
||||||
|
Poco::File socket_file(input_socket_file_path);
|
||||||
if (socket_file.exists())
|
if (socket_file.exists())
|
||||||
{
|
{
|
||||||
socket_file.remove();
|
socket_file.remove();
|
||||||
logger().information("Seems that server is already running. Make sure that only one instance of server is running.");
|
logger().information(FRED("Seems that server is already running. Make sure that only one instance of server is running."));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -253,7 +263,7 @@ void FlippRServer::handle_config_file(const std::string &name, const std::string
|
|||||||
logger().information("Configuration \"" + name + "\" is not known.");
|
logger().information("Configuration \"" + name + "\" is not known.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
logger().information("Set " + name + " to " + value);
|
logger().information(KMAG "Set " + name + " to " + value + RST);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlippRServer::handle_help(const std::string& name, const std::string& value)
|
void FlippRServer::handle_help(const std::string& name, const std::string& value)
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ private:
|
|||||||
const char * OUTPUT_SOCKET_NAME = "S.flippR_driver.out";
|
const char * OUTPUT_SOCKET_NAME = "S.flippR_driver.out";
|
||||||
const std::vector<std::string> REQUIRED_CONFIG_KEYS = {"display-config", "input-config", "lamp-config",
|
const std::vector<std::string> REQUIRED_CONFIG_KEYS = {"display-config", "input-config", "lamp-config",
|
||||||
"matrix-config", "solenoid-config", "sound-config"};
|
"matrix-config", "solenoid-config", "sound-config"};
|
||||||
|
std::string output_socket_file_path, input_socket_file_path;
|
||||||
int input_port;
|
int input_port;
|
||||||
int output_port;
|
int output_port;
|
||||||
|
|
||||||
@@ -62,9 +63,6 @@ private:
|
|||||||
|
|
||||||
std::unique_ptr<Poco::Net::HTTPServer> output_server;
|
std::unique_ptr<Poco::Net::HTTPServer> output_server;
|
||||||
std::unique_ptr<Poco::Net::TCPServer> input_server;
|
std::unique_ptr<Poco::Net::TCPServer> input_server;
|
||||||
|
|
||||||
Poco::File output_socket_file, input_socket_file;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user