Skip to content

Commit

Permalink
more gracefull wait for pg
Browse files Browse the repository at this point in the history
  • Loading branch information
antoine-de committed Oct 25, 2018
1 parent 17efdc3 commit f0ffba4
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 56 deletions.
3 changes: 3 additions & 0 deletions importer/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ ijson = "*"
simplejson = "*"
cffi = "*"
fire = "*"
retrying = "*"


[requires]

python_version = "3.6"


[dev-packages]

124 changes: 69 additions & 55 deletions importer/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions importer/import.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
import ijson.backends.yajl2_cffi as ijson
import simplejson as json
import fire
from retrying import retry


# we wait a bit for postgres to be ready since if used with docker, so docker might take a while to start
@retry(stop_max_delay=10000, retry_on_exception=psycopg2.OperationalError)
def _pg_connect():
dbname = environ.get('POSTGRES_DB')
user = environ.get('POSTGRES_USER')
Expand Down
1 change: 0 additions & 1 deletion tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ def pop_stack(ctx, build_dockers=False):
if build_dockers:
ctx.run("docker-compose build --pull")
ctx.run("docker-compose up -d")
ctx.run("sleep 5") # TODO do better to wait for pg

def _run_container(ctx, container_name, job):
main_docker_files = _get_docker_compose()
Expand Down

0 comments on commit f0ffba4

Please sign in to comment.