From 4d8760507da2cbcb0cbb6296c177244f84aec14b Mon Sep 17 00:00:00 2001 From: Thorsten Date: Thu, 12 Mar 2020 16:26:57 +0100 Subject: [PATCH] fix deployment, make sure rabbitmq is up --- deploy/roles/urlbot/templates/urlbot-chat.service | 3 ++- deploy/roles/urlbot/templates/urlbot-worker.service | 3 ++- deploy/roles/urlbot/templates/wait-for-rabbitmq.sh | 7 +++++++ 3 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 deploy/roles/urlbot/templates/wait-for-rabbitmq.sh diff --git a/deploy/roles/urlbot/templates/urlbot-chat.service b/deploy/roles/urlbot/templates/urlbot-chat.service index eb037de..b2eaef9 100644 --- a/deploy/roles/urlbot/templates/urlbot-chat.service +++ b/deploy/roles/urlbot/templates/urlbot-chat.service @@ -2,6 +2,7 @@ Description=jabber bot entertaining and supporting activity on jabber MUCs [Service] +ExecStartPre=/home/{{ botuser }}/wait-for-rabbitmq.sh ExecStart={{ venv_chatbot }}/bin/urlbotd-chat WorkingDirectory=/home/{{ botuser }}/urlbot-v3/ StandardOutput=journal+console @@ -9,4 +10,4 @@ StandardError=journal+console Restart=always [Install] -WantedBy=multi-user.target +WantedBy=default.target diff --git a/deploy/roles/urlbot/templates/urlbot-worker.service b/deploy/roles/urlbot/templates/urlbot-worker.service index 67639eb..a035685 100644 --- a/deploy/roles/urlbot/templates/urlbot-worker.service +++ b/deploy/roles/urlbot/templates/urlbot-worker.service @@ -2,6 +2,7 @@ Description=jabber bot entertaining and supporting activity on jabber MUCs [Service] +ExecStartPre=/home/{{ botuser }}/wait-for-rabbitmq.sh ExecStart={{ venv_worker }}/bin/urlbotd-worker WorkingDirectory=/home/{{ botuser }}/urlbot-v3/ StandardOutput=journal+console @@ -9,4 +10,4 @@ StandardError=journal+console Restart=always [Install] -WantedBy=multi-user.target +WantedBy=default.target diff --git a/deploy/roles/urlbot/templates/wait-for-rabbitmq.sh b/deploy/roles/urlbot/templates/wait-for-rabbitmq.sh new file mode 100644 index 0000000..59d65ba --- /dev/null +++ b/deploy/roles/urlbot/templates/wait-for-rabbitmq.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# TODO: parse amqp_uri, insert here +while ! echo > /dev/tcp/localhost/5672; do + echo "waiting for remote service..." + sleep 5s +done -- 2.39.2