-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #567 from FJNR-inc/documentation-add_docker_docume…
…ntation Documentation add docker documentation
- Loading branch information
Showing
5 changed files
with
83 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ DATABASE_URL=postgres://root:my_password@db:5432/blitz | |
## GENERAL SETTINGS | ||
DEBUG=True | ||
SECRET_KEY=NSH1FNjqRuZCZA2MxM7pNSH1FNjqRuZCZA2MxM7p | ||
ALLOWED_HOSTS=127.0.0.1, localhost, | ||
ALLOWED_HOSTS=127.0.0.1, localhost, 0.0.0.0 | ||
#ADMINS=("You", "[email protected]"), | ||
MAILCHIMP_API_KEY=00000000000000000000000000000000-aa00 #fake key | ||
MAILCHIMP_SUBSCRIBE_LIST_ID=1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import os | ||
import logging | ||
from time import time, sleep | ||
import psycopg2 | ||
check_timeout = os.getenv("POSTGRES_CHECK_TIMEOUT", 30) | ||
check_interval = os.getenv("POSTGRES_CHECK_INTERVAL", 1) | ||
interval_unit = "second" if check_interval == 1 else "seconds" | ||
config = { | ||
"dbname": os.getenv("POSTGRES_DB", "postgres"), | ||
"user": os.getenv("POSTGRES_USER", "postgres"), | ||
"password": os.getenv("POSTGRES_PASSWORD", ""), | ||
"host": os.getenv("DATABASE_URL", "postgres") | ||
} | ||
|
||
start_time = time() | ||
logger = logging.getLogger() | ||
logger.setLevel(logging.INFO) | ||
logger.addHandler(logging.StreamHandler()) | ||
|
||
|
||
def pg_isready(host, user, password, dbname): | ||
while time() - start_time < check_timeout: | ||
try: | ||
conn = psycopg2.connect(**vars()) | ||
logger.info("Postgres is ready! ✨ 💅") | ||
conn.close() | ||
return True | ||
except psycopg2.OperationalError: | ||
logger.info( | ||
f"Postgres isn't ready. Waiting for {check_interval} " | ||
f"{interval_unit}..." | ||
) | ||
sleep(check_interval) | ||
|
||
logger.error( | ||
f"We could not connect to Postgres within {check_timeout} seconds." | ||
) | ||
return False | ||
|
||
|
||
pg_isready(**config) |