From 14361e5ec7950cd1346a3a6aa15848231729740f Mon Sep 17 00:00:00 2001
From: Sergey Yakubov <sergey.yakubov@desy.de>
Date: Fri, 17 Aug 2018 14:55:53 +0200
Subject: [PATCH] change receiver health-check to ps

---
 deploy/nomad_jobs/asapo-receivers.nmd.in | 6 ++++--
 receiver/src/connection.cpp              | 2 +-
 receiver/src/receiver.cpp                | 2 +-
 receiver/unittests/test_connection.cpp   | 2 +-
 receiver/unittests/test_receiver.cpp     | 2 +-
 5 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/deploy/nomad_jobs/asapo-receivers.nmd.in b/deploy/nomad_jobs/asapo-receivers.nmd.in
index ef453031a..8d5858177 100644
--- a/deploy/nomad_jobs/asapo-receivers.nmd.in
+++ b/deploy/nomad_jobs/asapo-receivers.nmd.in
@@ -44,11 +44,13 @@ job "asapo-receivers" {
       }
 
       service {
-        port = "recv"
         name = "asapo-receiver"
+        port = "recv"
         check {
           name     = "asapo-receiver-alive"
-          type     = "tcp"
+          type     = "script"
+          command  = "/bin/ps"
+          args     = ["-fC","receiver"]
           interval = "10s"
           timeout  = "2s"
         }
diff --git a/receiver/src/connection.cpp b/receiver/src/connection.cpp
index d736e5223..0e30d5463 100644
--- a/receiver/src/connection.cpp
+++ b/receiver/src/connection.cpp
@@ -44,7 +44,7 @@ void Connection::Listen() const noexcept {
     }
     io__->CloseSocket(socket_fd_, nullptr);
     statistics__->Send();
-    log__->Debug("disconnected from " + address_);
+    log__->Info("disconnected from " + address_);
 }
 
 
diff --git a/receiver/src/receiver.cpp b/receiver/src/receiver.cpp
index 41be7ea8a..9a94afe45 100644
--- a/receiver/src/receiver.cpp
+++ b/receiver/src/receiver.cpp
@@ -54,7 +54,7 @@ void Receiver::ProcessConnections(Error* err) {
 }
 
 void Receiver::StartNewConnectionInSeparateThread(int connection_socket_fd, const std::string& address)  {
-    log__->Debug("new connection from " + address);
+    log__->Info("new connection from " + address);
     auto thread = io__->NewThread([connection_socket_fd, address] {
         auto connection = std::unique_ptr<Connection>(new Connection(connection_socket_fd, address, GetReceiverConfig()->tag));
         connection->Listen();
diff --git a/receiver/unittests/test_connection.cpp b/receiver/unittests/test_connection.cpp
index ea9204ddd..2ce08a8fc 100644
--- a/receiver/unittests/test_connection.cpp
+++ b/receiver/unittests/test_connection.cpp
@@ -102,7 +102,7 @@ class ConnectionTests : public Test {
         connection->requests_dispatcher__ = std::unique_ptr<asapo::RequestsDispatcher> {&mock_dispatcher};
         EXPECT_CALL(mock_io, CloseSocket_t(_, _));
         EXPECT_CALL(mock_statictics, Send_t());
-        EXPECT_CALL(mock_logger, Debug(HasSubstr("disconnected")));
+        EXPECT_CALL(mock_logger, Info(HasSubstr("disconnected")));
 
     }
     void TearDown() override {
diff --git a/receiver/unittests/test_receiver.cpp b/receiver/unittests/test_receiver.cpp
index 52527fa9e..47b42e746 100644
--- a/receiver/unittests/test_receiver.cpp
+++ b/receiver/unittests/test_receiver.cpp
@@ -102,7 +102,7 @@ TEST_F(StartListenerFixture, Ok) {
         Return(nullptr)
     );
 
-    EXPECT_CALL(mock_logger, Debug(HasSubstr("new connection from " + expected_address)));
+    EXPECT_CALL(mock_logger, Info(HasSubstr("new connection from " + expected_address)));
 
 
     receiver.Listen(expected_address, &err, true);
-- 
GitLab