diff --git a/FlippR-Driver/networking/FlippRServer.cpp b/FlippR-Driver/networking/FlippRServer.cpp index 6ee2322..bc27494 100644 --- a/FlippR-Driver/networking/FlippRServer.cpp +++ b/FlippR-Driver/networking/FlippRServer.cpp @@ -98,6 +98,14 @@ void FlippRServer::uninitialize() this->output_server->stop(); 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& args) { if(!help_requested) { - logger().information("Server running!"); + logger().information(FGRN("Server running!")); waitForTerminationRequest(); } 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); - 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()) socket_file.remove(); @@ -196,11 +205,12 @@ TCPServer* FlippRServer::build_input_server() { 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()) { 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."); 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) diff --git a/FlippR-Driver/networking/FlippRServer.h b/FlippR-Driver/networking/FlippRServer.h index 6f8ef70..9dfc480 100644 --- a/FlippR-Driver/networking/FlippRServer.h +++ b/FlippR-Driver/networking/FlippRServer.h @@ -48,6 +48,7 @@ private: const char * OUTPUT_SOCKET_NAME = "S.flippR_driver.out"; const std::vector REQUIRED_CONFIG_KEYS = {"display-config", "input-config", "lamp-config", "matrix-config", "solenoid-config", "sound-config"}; + std::string output_socket_file_path, input_socket_file_path; int input_port; int output_port; @@ -62,9 +63,6 @@ private: std::unique_ptr output_server; std::unique_ptr input_server; - - Poco::File output_socket_file, input_socket_file; - }; };