From ad89114be9905cb723c0eaf14ff8f4431fef34af Mon Sep 17 00:00:00 2001
From: Sergey Yakubov <sergey.yakubov@desy.de>
Date: Tue, 1 Oct 2019 17:02:02 +0200
Subject: [PATCH] kill nginx properly after each job

---
 broker/src/asapo_broker/main/broker.go                          | 2 +-
 examples/consumer/getnext_broker/check_windows.bat              | 2 +-
 examples/consumer/getnext_broker_python/check_windows.bat       | 2 +-
 examples/pipeline/in_to_out/check_windows.bat                   | 2 +-
 examples/pipeline/in_to_out_python/check_windows.bat            | 2 +-
 .../bug_fixes/producer_send_after_restart/check_windows.bat     | 2 +-
 tests/automatic/consumer/consumer_api/check_windows.bat         | 2 +-
 tests/automatic/consumer/consumer_api_python/check_windows.bat  | 2 +-
 .../consumer/next_multithread_broker/check_windows.bat          | 2 +-
 tests/automatic/full_chain/simple_chain/check_windows.bat       | 2 +-
 .../automatic/full_chain/simple_chain_dataset/check_windows.bat | 2 +-
 .../automatic/full_chain/simple_chain_filegen/check_windows.bat | 2 +-
 .../full_chain/simple_chain_filegen_batches/check_windows.bat   | 2 +-
 .../simple_chain_filegen_multisource/check_windows.bat          | 2 +-
 .../simple_chain_filegen_readdata_cache/check_windows.bat       | 2 +-
 .../simple_chain_filegen_readdata_file/check_windows.bat        | 2 +-
 .../full_chain/simple_chain_metadata/check_windows.bat          | 2 +-
 .../full_chain/simple_chain_usermeta_python/check_windows.bat   | 2 +-
 tests/automatic/full_chain/two_beamlines/check_windows.bat      | 2 +-
 tests/automatic/full_chain/two_streams/check_windows.bat        | 2 +-
 tests/automatic/producer/python_api/check_linux.sh              | 2 +-
 tests/automatic/producer/python_api/check_windows.bat           | 2 +-
 .../producer_receiver/transfer_datasets/check_windows.bat       | 2 +-
 .../producer_receiver/transfer_single_file/check_windows.bat    | 2 +-
 24 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/broker/src/asapo_broker/main/broker.go b/broker/src/asapo_broker/main/broker.go
index 8b935e679..a0cebee6f 100644
--- a/broker/src/asapo_broker/main/broker.go
+++ b/broker/src/asapo_broker/main/broker.go
@@ -45,7 +45,7 @@ func main() {
 
 	err = server.InitDB(NewDefaultDatabase())
 	if err != nil {
-		log.Fatal(err.Error())
+		log.Error(err.Error())
 	}
 	defer server.CleanupDB()
 	server.Start()
diff --git a/examples/consumer/getnext_broker/check_windows.bat b/examples/consumer/getnext_broker/check_windows.bat
index 5173773f5..fb2e3816a 100644
--- a/examples/consumer/getnext_broker/check_windows.bat
+++ b/examples/consumer/getnext_broker/check_windows.bat
@@ -27,5 +27,5 @@ exit /b 1
 c:\opt\consul\nomad stop discovery
 c:\opt\consul\nomad stop broker
 c:\opt\consul\nomad stop nginx
-c:\opt\consul\nomad run nginx_kill.nmd  && nomad stop -yes -purge nginx_kill
+c:\opt\consul\nomad run nginx_kill.nmd  && c:\opt\consul\nomad stop -yes -purge nginx_kill
 echo db.dropDatabase() | %mongo_exe% %database_name%
diff --git a/examples/consumer/getnext_broker_python/check_windows.bat b/examples/consumer/getnext_broker_python/check_windows.bat
index 29ab51360..3c35ea11f 100644
--- a/examples/consumer/getnext_broker_python/check_windows.bat
+++ b/examples/consumer/getnext_broker_python/check_windows.bat
@@ -51,5 +51,5 @@ exit /b 1
 c:\opt\consul\nomad stop discovery
 c:\opt\consul\nomad stop broker
 c:\opt\consul\nomad stop nginx
-c:\opt\consul\nomad run nginx_kill.nmd  && nomad stop -yes -purge nginx_kill
+c:\opt\consul\nomad run nginx_kill.nmd  && c:\opt\consul\nomad stop -yes -purge nginx_kill
 echo db.dropDatabase() | %mongo_exe% %database_name%
diff --git a/examples/pipeline/in_to_out/check_windows.bat b/examples/pipeline/in_to_out/check_windows.bat
index 099d19f68..30a6407fa 100644
--- a/examples/pipeline/in_to_out/check_windows.bat
+++ b/examples/pipeline/in_to_out/check_windows.bat
@@ -67,7 +67,7 @@ exit /b 1
 c:\opt\consul\nomad stop discovery
 c:\opt\consul\nomad stop broker
 c:\opt\consul\nomad stop nginx
-c:\opt\consul\nomad run nginx_kill.nmd  && nomad stop -yes -purge nginx_kill
+c:\opt\consul\nomad run nginx_kill.nmd  && c:\opt\consul\nomad stop -yes -purge nginx_kill
 c:\opt\consul\nomad stop receiver
 c:\opt\consul\nomad stop authorizer
 
diff --git a/examples/pipeline/in_to_out_python/check_windows.bat b/examples/pipeline/in_to_out_python/check_windows.bat
index a3dbdeea2..a4d705c93 100644
--- a/examples/pipeline/in_to_out_python/check_windows.bat
+++ b/examples/pipeline/in_to_out_python/check_windows.bat
@@ -60,7 +60,7 @@ exit /b 1
 c:\opt\consul\nomad stop discovery
 c:\opt\consul\nomad stop broker
 c:\opt\consul\nomad stop nginx
-c:\opt\consul\nomad run nginx_kill.nmd  && nomad stop -yes -purge nginx_kill
+c:\opt\consul\nomad run nginx_kill.nmd  && c:\opt\consul\nomad stop -yes -purge nginx_kill
 c:\opt\consul\nomad stop receiver
 c:\opt\consul\nomad stop authorizer
 
diff --git a/tests/automatic/bug_fixes/producer_send_after_restart/check_windows.bat b/tests/automatic/bug_fixes/producer_send_after_restart/check_windows.bat
index b4ef7c054..170c10d0c 100644
--- a/tests/automatic/bug_fixes/producer_send_after_restart/check_windows.bat
+++ b/tests/automatic/bug_fixes/producer_send_after_restart/check_windows.bat
@@ -66,7 +66,7 @@ c:\opt\consul\nomad stop discovery
 c:\opt\consul\nomad stop broker
 c:\opt\consul\nomad stop authorizer
 c:\opt\consul\nomad stop nginx
-c:\opt\consul\nomad run nginx_kill.nmd  && nomad stop -yes -purge nginx_kill
+c:\opt\consul\nomad run nginx_kill.nmd  && c:\opt\consul\nomad stop -yes -purge nginx_kill
 
 rmdir /S /Q %receiver_root_folder%
 rmdir /S /Q c:\tmp\asapo\test_in\test1
diff --git a/tests/automatic/consumer/consumer_api/check_windows.bat b/tests/automatic/consumer/consumer_api/check_windows.bat
index 27bfdd190..b3489c09a 100644
--- a/tests/automatic/consumer/consumer_api/check_windows.bat
+++ b/tests/automatic/consumer/consumer_api/check_windows.bat
@@ -39,7 +39,7 @@ exit /b 1
 c:\opt\consul\nomad stop discovery
 c:\opt\consul\nomad stop broker
 c:\opt\consul\nomad stop nginx
-c:\opt\consul\nomad run nginx_kill.nmd  && nomad stop -yes -purge nginx_kill
+c:\opt\consul\nomad run nginx_kill.nmd  && c:\opt\consul\nomad stop -yes -purge nginx_kill
 echo db.dropDatabase() | %mongo_exe% %database_name%
 del "1 1_1"
 
diff --git a/tests/automatic/consumer/consumer_api_python/check_windows.bat b/tests/automatic/consumer/consumer_api_python/check_windows.bat
index 5af7b07fb..3d91e3db3 100644
--- a/tests/automatic/consumer/consumer_api_python/check_windows.bat
+++ b/tests/automatic/consumer/consumer_api_python/check_windows.bat
@@ -40,6 +40,6 @@ exit /b 1
 c:\opt\consul\nomad stop discovery
 c:\opt\consul\nomad stop broker
 c:\opt\consul\nomad stop nginx
-c:\opt\consul\nomad run nginx_kill.nmd  && nomad stop -yes -purge nginx_kill
+c:\opt\consul\nomad run nginx_kill.nmd  && c:\opt\consul\nomad stop -yes -purge nginx_kill
 echo db.dropDatabase() | %mongo_exe% %database_name%
 del "1 1_1"
diff --git a/tests/automatic/consumer/next_multithread_broker/check_windows.bat b/tests/automatic/consumer/next_multithread_broker/check_windows.bat
index 1d95f02d4..6a349c086 100644
--- a/tests/automatic/consumer/next_multithread_broker/check_windows.bat
+++ b/tests/automatic/consumer/next_multithread_broker/check_windows.bat
@@ -25,5 +25,5 @@ exit /b 1
 c:\opt\consul\nomad stop discovery
 c:\opt\consul\nomad stop broker
 c:\opt\consul\nomad stop nginx
-c:\opt\consul\nomad run nginx_kill.nmd  && nomad stop -yes -purge nginx_kill
+c:\opt\consul\nomad run nginx_kill.nmd  && c:\opt\consul\nomad stop -yes -purge nginx_kill
 echo db.dropDatabase() | %mongo_exe% %database_name%
diff --git a/tests/automatic/full_chain/simple_chain/check_windows.bat b/tests/automatic/full_chain/simple_chain/check_windows.bat
index c15b69336..38ce093a3 100644
--- a/tests/automatic/full_chain/simple_chain/check_windows.bat
+++ b/tests/automatic/full_chain/simple_chain/check_windows.bat
@@ -44,7 +44,7 @@ c:\opt\consul\nomad stop discovery
 c:\opt\consul\nomad stop broker
 c:\opt\consul\nomad stop authorizer
 c:\opt\consul\nomad stop nginx
-c:\opt\consul\nomad run nginx_kill.nmd  && nomad stop -yes -purge nginx_kill
+c:\opt\consul\nomad run nginx_kill.nmd  && c:\opt\consul\nomad stop -yes -purge nginx_kill
 rmdir /S /Q %receiver_root_folder%
 del /f token
 echo db.dropDatabase() | %mongo_exe% %beamtime_id%_detector
diff --git a/tests/automatic/full_chain/simple_chain_dataset/check_windows.bat b/tests/automatic/full_chain/simple_chain_dataset/check_windows.bat
index cb7fa5f8c..2e3ae695f 100644
--- a/tests/automatic/full_chain/simple_chain_dataset/check_windows.bat
+++ b/tests/automatic/full_chain/simple_chain_dataset/check_windows.bat
@@ -44,7 +44,7 @@ c:\opt\consul\nomad stop discovery
 c:\opt\consul\nomad stop broker
 c:\opt\consul\nomad stop authorizer
 c:\opt\consul\nomad stop nginx
-c:\opt\consul\nomad run nginx_kill.nmd  && nomad stop -yes -purge nginx_kill
+c:\opt\consul\nomad run nginx_kill.nmd  && c:\opt\consul\nomad stop -yes -purge nginx_kill
 rmdir /S /Q %receiver_root_folder%
 del /f token
 echo db.dropDatabase() | %mongo_exe% %beamtime_id%_detector
diff --git a/tests/automatic/full_chain/simple_chain_filegen/check_windows.bat b/tests/automatic/full_chain/simple_chain_filegen/check_windows.bat
index 2579f63b3..a98eae7e6 100644
--- a/tests/automatic/full_chain/simple_chain_filegen/check_windows.bat
+++ b/tests/automatic/full_chain/simple_chain_filegen/check_windows.bat
@@ -56,7 +56,7 @@ c:\opt\consul\nomad stop discovery
 c:\opt\consul\nomad stop broker
 c:\opt\consul\nomad stop authorizer
 c:\opt\consul\nomad stop nginx
-c:\opt\consul\nomad run nginx_kill.nmd  && nomad stop -yes -purge nginx_kill
+c:\opt\consul\nomad run nginx_kill.nmd  && c:\opt\consul\nomad stop -yes -purge nginx_kill
 rmdir /S /Q %receiver_root_folder%
 rmdir /S /Q c:\tmp\asapo\test_in\test1
 rmdir /S /Q c:\tmp\asapo\test_in\test2
diff --git a/tests/automatic/full_chain/simple_chain_filegen_batches/check_windows.bat b/tests/automatic/full_chain/simple_chain_filegen_batches/check_windows.bat
index 96f6ce79f..ba872e426 100644
--- a/tests/automatic/full_chain/simple_chain_filegen_batches/check_windows.bat
+++ b/tests/automatic/full_chain/simple_chain_filegen_batches/check_windows.bat
@@ -57,7 +57,7 @@ c:\opt\consul\nomad stop discovery
 c:\opt\consul\nomad stop broker
 c:\opt\consul\nomad stop authorizer
 c:\opt\consul\nomad stop nginx
-c:\opt\consul\nomad run nginx_kill.nmd  && nomad stop -yes -purge nginx_kill
+c:\opt\consul\nomad run nginx_kill.nmd  && c:\opt\consul\nomad stop -yes -purge nginx_kill
 rmdir /S /Q %receiver_root_folder%
 rmdir /S /Q c:\tmp\asapo\test_in\test1
 rmdir /S /Q c:\tmp\asapo\test_in\test2
diff --git a/tests/automatic/full_chain/simple_chain_filegen_multisource/check_windows.bat b/tests/automatic/full_chain/simple_chain_filegen_multisource/check_windows.bat
index e4063095f..63684cf4e 100644
--- a/tests/automatic/full_chain/simple_chain_filegen_multisource/check_windows.bat
+++ b/tests/automatic/full_chain/simple_chain_filegen_multisource/check_windows.bat
@@ -63,7 +63,7 @@ c:\opt\consul\nomad stop discovery
 c:\opt\consul\nomad stop broker
 c:\opt\consul\nomad stop authorizer
 c:\opt\consul\nomad stop nginx
-c:\opt\consul\nomad run nginx_kill.nmd  && nomad stop -yes -purge nginx_kill
+c:\opt\consul\nomad run nginx_kill.nmd  && c:\opt\consul\nomad stop -yes -purge nginx_kill
 rmdir /S /Q %receiver_root_folder%
 rmdir /S /Q c:\tmp\asapo\test_in\test1
 rmdir /S /Q c:\tmp\asapo\test_in\test2
diff --git a/tests/automatic/full_chain/simple_chain_filegen_readdata_cache/check_windows.bat b/tests/automatic/full_chain/simple_chain_filegen_readdata_cache/check_windows.bat
index f505c6699..d7b66fe93 100644
--- a/tests/automatic/full_chain/simple_chain_filegen_readdata_cache/check_windows.bat
+++ b/tests/automatic/full_chain/simple_chain_filegen_readdata_cache/check_windows.bat
@@ -60,7 +60,7 @@ c:\opt\consul\nomad stop discovery
 c:\opt\consul\nomad stop broker
 c:\opt\consul\nomad stop authorizer
 c:\opt\consul\nomad stop nginx
-c:\opt\consul\nomad run nginx_kill.nmd  && nomad stop -yes -purge nginx_kill
+c:\opt\consul\nomad run nginx_kill.nmd  && c:\opt\consul\nomad stop -yes -purge nginx_kill
 rmdir /S /Q %receiver_root_folder%
 rmdir /S /Q c:\tmp\asapo\test_in\test1
 rmdir /S /Q c:\tmp\asapo\test_in\test2
diff --git a/tests/automatic/full_chain/simple_chain_filegen_readdata_file/check_windows.bat b/tests/automatic/full_chain/simple_chain_filegen_readdata_file/check_windows.bat
index 432cfd426..ce45d9597 100644
--- a/tests/automatic/full_chain/simple_chain_filegen_readdata_file/check_windows.bat
+++ b/tests/automatic/full_chain/simple_chain_filegen_readdata_file/check_windows.bat
@@ -60,7 +60,7 @@ c:\opt\consul\nomad stop discovery
 c:\opt\consul\nomad stop broker
 c:\opt\consul\nomad stop authorizer
 c:\opt\consul\nomad stop nginx
-c:\opt\consul\nomad run nginx_kill.nmd  && nomad stop -yes -purge nginx_kill
+c:\opt\consul\nomad run nginx_kill.nmd  && c:\opt\consul\nomad stop -yes -purge nginx_kill
 rmdir /S /Q %receiver_root_folder%
 rmdir /S /Q c:\tmp\asapo\test_in\test1
 rmdir /S /Q c:\tmp\asapo\test_in\test2
diff --git a/tests/automatic/full_chain/simple_chain_metadata/check_windows.bat b/tests/automatic/full_chain/simple_chain_metadata/check_windows.bat
index 58ac4c035..0627cdd21 100644
--- a/tests/automatic/full_chain/simple_chain_metadata/check_windows.bat
+++ b/tests/automatic/full_chain/simple_chain_metadata/check_windows.bat
@@ -42,7 +42,7 @@ c:\opt\consul\nomad stop discovery
 c:\opt\consul\nomad stop broker
 c:\opt\consul\nomad stop authorizer
 c:\opt\consul\nomad stop nginx
-c:\opt\consul\nomad run nginx_kill.nmd  && nomad stop -yes -purge nginx_kill
+c:\opt\consul\nomad run nginx_kill.nmd  && c:\opt\consul\nomad stop -yes -purge nginx_kill
 rmdir /S /Q %receiver_root_folder%
 del /f token
 echo db.dropDatabase() | %mongo_exe% %beamtime_id%_detector
diff --git a/tests/automatic/full_chain/simple_chain_usermeta_python/check_windows.bat b/tests/automatic/full_chain/simple_chain_usermeta_python/check_windows.bat
index fe1b30a1e..f60eb6035 100644
--- a/tests/automatic/full_chain/simple_chain_usermeta_python/check_windows.bat
+++ b/tests/automatic/full_chain/simple_chain_usermeta_python/check_windows.bat
@@ -44,7 +44,7 @@ c:\opt\consul\nomad stop discovery
 c:\opt\consul\nomad stop broker
 c:\opt\consul\nomad stop authorizer
 c:\opt\consul\nomad stop nginx
-c:\opt\consul\nomad run nginx_kill.nmd  && nomad stop -yes -purge nginx_kill
+c:\opt\consul\nomad run nginx_kill.nmd  && c:\opt\consul\nomad stop -yes -purge nginx_kill
 rmdir /S /Q %receiver_root_folder%
 del /f token
 echo db.dropDatabase() | %mongo_exe% %beamtime_id%_detector
diff --git a/tests/automatic/full_chain/two_beamlines/check_windows.bat b/tests/automatic/full_chain/two_beamlines/check_windows.bat
index 33de538e4..16e353f58 100644
--- a/tests/automatic/full_chain/two_beamlines/check_windows.bat
+++ b/tests/automatic/full_chain/two_beamlines/check_windows.bat
@@ -58,7 +58,7 @@ c:\opt\consul\nomad stop discovery
 c:\opt\consul\nomad stop broker
 c:\opt\consul\nomad stop authorizer
 c:\opt\consul\nomad stop nginx
-c:\opt\consul\nomad run nginx_kill.nmd  && nomad stop -yes -purge nginx_kill
+c:\opt\consul\nomad run nginx_kill.nmd  && c:\opt\consul\nomad stop -yes -purge nginx_kill
 rmdir /S /Q %receiver_root_folder%
 del /f token1
 del /f token2
diff --git a/tests/automatic/full_chain/two_streams/check_windows.bat b/tests/automatic/full_chain/two_streams/check_windows.bat
index f2c247163..af2f4ec61 100644
--- a/tests/automatic/full_chain/two_streams/check_windows.bat
+++ b/tests/automatic/full_chain/two_streams/check_windows.bat
@@ -53,7 +53,7 @@ c:\opt\consul\nomad stop discovery
 c:\opt\consul\nomad stop broker
 c:\opt\consul\nomad stop authorizer
 c:\opt\consul\nomad stop nginx
-c:\opt\consul\nomad run nginx_kill.nmd  && nomad stop -yes -purge nginx_kill
+c:\opt\consul\nomad run nginx_kill.nmd  && c:\opt\consul\nomad stop -yes -purge nginx_kill
 rmdir /S /Q %receiver_root_folder%
 del /f token1
 del /f token2
diff --git a/tests/automatic/producer/python_api/check_linux.sh b/tests/automatic/producer/python_api/check_linux.sh
index 76ee5358e..e7654d394 100644
--- a/tests/automatic/producer/python_api/check_linux.sh
+++ b/tests/automatic/producer/python_api/check_linux.sh
@@ -17,7 +17,7 @@ Cleanup() {
     nomad stop discovery >/dev/null
     nomad stop authorizer >/dev/null
     nomad stop nginx >/dev/null
-    nomad run nginx_kill.nmd  && nomad stop -yes -purge nginx_kill > dev/null
+    nomad run nginx_kill.nmd  && nomad stop -yes -purge nginx_kill > /dev/null
     echo "db.dropDatabase()" | mongo ${beamtime_id}_${stream} >/dev/null
 }
 
diff --git a/tests/automatic/producer/python_api/check_windows.bat b/tests/automatic/producer/python_api/check_windows.bat
index 2f228a4e6..070a6e844 100644
--- a/tests/automatic/producer/python_api/check_windows.bat
+++ b/tests/automatic/producer/python_api/check_windows.bat
@@ -41,7 +41,7 @@ exit /b 1
 c:\opt\consul\nomad stop receiver
 c:\opt\consul\nomad stop discovery
 c:\opt\consul\nomad stop nginx
-c:\opt\consul\nomad run nginx_kill.nmd  && nomad stop -yes -purge nginx_kill
+c:\opt\consul\nomad run nginx_kill.nmd  && c:\opt\consul\nomad stop -yes -purge nginx_kill
 c:\opt\consul\nomad stop authorizer
 rmdir /S /Q %receiver_root_folder%
 echo db.dropDatabase() | %mongo_exe% %dbname%
diff --git a/tests/automatic/producer_receiver/transfer_datasets/check_windows.bat b/tests/automatic/producer_receiver/transfer_datasets/check_windows.bat
index d8b5fcf35..36c820e9c 100644
--- a/tests/automatic/producer_receiver/transfer_datasets/check_windows.bat
+++ b/tests/automatic/producer_receiver/transfer_datasets/check_windows.bat
@@ -45,7 +45,7 @@ exit /b 1
 c:\opt\consul\nomad stop receiver
 c:\opt\consul\nomad stop discovery
 c:\opt\consul\nomad stop nginx
-c:\opt\consul\nomad run nginx_kill.nmd  && nomad stop -yes -purge nginx_kill
+c:\opt\consul\nomad run nginx_kill.nmd  && c:\opt\consul\nomad stop -yes -purge nginx_kill
 c:\opt\consul\nomad stop authorizer
 rmdir /S /Q %receiver_root_folder%
 echo db.dropDatabase() | %mongo_exe% %beamtime_id%_detector
diff --git a/tests/automatic/producer_receiver/transfer_single_file/check_windows.bat b/tests/automatic/producer_receiver/transfer_single_file/check_windows.bat
index 4efa12c90..a42e99585 100644
--- a/tests/automatic/producer_receiver/transfer_single_file/check_windows.bat
+++ b/tests/automatic/producer_receiver/transfer_single_file/check_windows.bat
@@ -36,7 +36,7 @@ exit /b 1
 c:\opt\consul\nomad stop receiver
 c:\opt\consul\nomad stop discovery
 c:\opt\consul\nomad stop nginx
-c:\opt\consul\nomad run nginx_kill.nmd  && nomad stop -yes -purge nginx_kill
+c:\opt\consul\nomad run nginx_kill.nmd  && c:\opt\consul\nomad stop -yes -purge nginx_kill
 c:\opt\consul\nomad stop authorizer
 rmdir /S /Q %receiver_root_folder%
 echo db.dropDatabase() | %mongo_exe% %beamtime_id%_detector
-- 
GitLab