Skip to content
Browse files

Merge pull request #1836 from iNecas/bz/903388

903388 - fix service-wait script
  • Loading branch information...
2 parents 3bb6fe1 + 6bdc987 commit 0e537925982e9012a541b230b5e9601fe051dbea @iNecas iNecas committed Apr 3, 2013
Showing with 21 additions and 6 deletions.
  1. +5 −0 src/katello.spec
  2. +16 −6 src/script/service-wait
View
5 src/katello.spec
@@ -66,6 +66,11 @@ Requires: httpd
Requires: mod_ssl
Requires: openssl
Requires: elasticsearch
+
+# service-wait dependency
+Requires: wget
+Requires: curl
+
Requires: %{?scl_prefix}rubygems
Requires: %{?scl_prefix}rubygem(rails) >= 3.0.10
Requires: %{?scl_prefix}rubygem(haml) >= 3.1.2
View
22 src/script/service-wait
@@ -49,6 +49,19 @@ FOREMAN_TEST_URL=${FOREMAN_TEST_URL:-http://localhost:5500/foreman/api}
# for some services we add few extra seconds after start
ADDITIONAL_SLEEP=5
+wait_for_url() {
+ # we use wget first because it's able to retry from connrefused situation
+ /usr/bin/wget --timeout=1 --tries=$WAIT_MAX --retry-connrefused -qO-\
+ --no-check-certificate $1 > /dev/null
+ # then we double check with curl that the service is really
+ # available. wget is not able to retry from 'Unable to establish
+ # SSL connection.' error, which happens for example with tomcat6
+ /usr/bin/curl -ks --retry $WAIT_MAX --retry-delay 1 $1 > /dev/null
+ if ! [ $? = '0' ]; then
+ RETVAL=5
+ fi
+}
+
# before start or restart
before_start() {
test 1 -eq 1 # noop
@@ -59,16 +72,13 @@ after_start() {
case "$SERVICE" in
tomcat6|tomcat7)
# RHBZ 789288 - wait until data port is avaiable
- /usr/bin/wget --timeout=1 --tries=$WAIT_MAX --retry-connrefused -qO- --no-check-certificate $TOMCAT_TEST_URL >/dev/null
- sleep $ADDITIONAL_SLEEP
+ wait_for_url $TOMCAT_TEST_URL
;;
elasticsearch)
- /usr/bin/wget --timeout=1 --tries=$WAIT_MAX --retry-connrefused -qO- --no-check-certificate $ELASTICSEARCH_TEST_URL >/dev/null
- sleep $ADDITIONAL_SLEEP
+ wait_for_url $ELASTICSEARCH_TEST_URL
;;
foreman)
- /usr/bin/wget --timeout=1 --tries=$WAIT_MAX --retry-connrefused -qO- --no-check-certificate $FOREMAN_TEST_URL >/dev/null
- sleep $ADDITIONAL_SLEEP
+ wait_for_url $FOREMAN_TEST_URL
;;
mongod)
# RHBZ 824405 - wait until service is avaiable

0 comments on commit 0e53792

Please sign in to comment.
Something went wrong with that request. Please try again.