Skip to content

Commit

Permalink
Using s6 service ready notification instead of sleep
Browse files Browse the repository at this point in the history
  • Loading branch information
unkcpz committed Jun 7, 2024
1 parent ccb5628 commit 09e4fc9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
5 changes: 0 additions & 5 deletions .docker/aiida-core-base/s6-assets/init/aiida-prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ verdi config set warnings.development_version False
# If the environment variable `SETUP_DEFAULT_AIIDA_PROFILE` is not set, set it to `true`.
if [[ ${SETUP_DEFAULT_AIIDA_PROFILE:-true} == true ]] && ! verdi profile show ${AIIDA_PROFILE_NAME} &> /dev/null; then

# For the container that includes the services, this script is called as soon as the RabbitMQ startup script has
# been launched, but it can take a while for the service to come up. If ``verdi presto`` is called straight away
# it is possible it tries to connect to the service before that and it will configure the profile without a broker.
sleep 5

# Create AiiDA profile.
verdi presto \
--verbosity info \
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

exec rabbitmq-diagnostics check_running > /dev/null
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3
13 changes: 11 additions & 2 deletions .docker/aiida-core-with-services/s6-assets/s6-rc.d/rabbitmq/run
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,14 @@

with-contenv

foreground { s6-echo "Calling /etc/init/rabbitmq.sh" }
rabbitmq-server
foreground { s6-echo "Starting RMQ server and notifying back when the service is ready" }


# For the container that includes the services, aiida-prepare.sh script is called as soon as the RabbitMQ startup script has
# been launched, but it can take a while for the RMQ service to come up. If ``verdi presto`` is called straight away
# it is possible it tries to connect to the service before that and it will configure the profile without a broker.
# Here we use s6-notifyoncheck to do the polling healthy check of the readyness of RMQ service.
#
# -w 500: 500 ms between two invocations of ./data/check

s6-notifyoncheck -w 500 rabbitmq-server

0 comments on commit 09e4fc9

Please sign in to comment.