Initial commit for script to retry server startup until Postgres is ready
Project: http://git-wip-us.apache.org/repos/asf/incubator-senssoft/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-senssoft/commit/d8f0f7c6 Tree: http://git-wip-us.apache.org/repos/asf/incubator-senssoft/tree/d8f0f7c6 Diff: http://git-wip-us.apache.org/repos/asf/incubator-senssoft/diff/d8f0f7c6 Branch: refs/heads/asf-site Commit: d8f0f7c6930cd17f042c8a188e57abc166e9fedb Parents: 00c99eb Author: Rob Foley <rob.foley...@gmail.com> Authored: Wed Mar 22 17:16:48 2017 -0400 Committer: Rob Foley <rob.foley...@gmail.com> Committed: Wed Mar 22 17:16:48 2017 -0400 ---------------------------------------------------------------------- docker/tap/wait-for-postgres.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-senssoft/blob/d8f0f7c6/docker/tap/wait-for-postgres.sh ---------------------------------------------------------------------- diff --git a/docker/tap/wait-for-postgres.sh b/docker/tap/wait-for-postgres.sh new file mode 100644 index 0000000..96084c7 --- /dev/null +++ b/docker/tap/wait-for-postgres.sh @@ -0,0 +1,27 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#!/bin/bash + +delay=2 +sleep $delay +n=0 +until [ $n -ge 3 ] +do + python manage.py migrate && python manage.py runserver 0.0.0.0:8000 && break + echo "Retrying connection in $delay seconds..." + n=$[$n+1] + sleep 2 +done