From f2452727960e3709e0381b02c049ce08b6858892 Mon Sep 17 00:00:00 2001 From: lza_menace Date: Sat, 22 Aug 2020 12:34:02 -0700 Subject: [PATCH] setup database checks for health page --- docker-compose.yaml | 6 +++++- wowstash/config.example.py | 10 +++++++++- wowstash/run.py | 4 ++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 0fcff83..30be51f 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -2,13 +2,17 @@ version: '3' services: db: image: postgres:9.6.15-alpine + container_name: db ports: - 5432:5432 environment: POSTGRES_PASSWORD: ${DB_PASS} POSTGRES_USER: ${DB_USER} POSTGRES_DB: ${DB_NAME} - redis: + volumes: + - ./data:/var/lib/postgresql/data + cache: image: redis:latest + container_name: cache ports: - 6379:6379 diff --git a/wowstash/config.example.py b/wowstash/config.example.py index 187805e..34e2381 100644 --- a/wowstash/config.example.py +++ b/wowstash/config.example.py @@ -29,6 +29,13 @@ SESSION_PERMANENT = True REDIS_HOST = 'localhost' REDIS_PORT = 6379 +# Database +DB_HOST = 'localhost' +DB_PORT = 5432 +DB_NAME = 'wowstash' +DB_USER = 'wowstash' +DB_PASS = 'zzzzzzzzz' + # Development TEMPLATES_AUTO_RELOAD = True @@ -36,5 +43,6 @@ TEMPLATES_AUTO_RELOAD = True SOCIAL = { 'envelope': 'mailto:admin@domain.co', 'twitter': 'https://twitter.com/your_twitter_handle', - 'comment-dots': 'https://webchat.freenode.net/?room=#wownero' + 'comment': 'https://webchat.freenode.net/?room=#wownero', + 'reddit': 'https://reddit.com/r/wownero' } diff --git a/wowstash/run.py b/wowstash/run.py index 08435d0..82299ca 100644 --- a/wowstash/run.py +++ b/wowstash/run.py @@ -4,6 +4,7 @@ from datetime import timedelta, datetime from redis import Redis from wowstash.library.jsonrpc import daemon from wowstash.library.info import info +from wowstash.library.db import Database from wowstash import config # from wowstash.blueprints.account import account_bp # from wowstash.blueprints.authentication import authentication_bp @@ -30,10 +31,9 @@ def index(): @app.route('/health') def health(): - print(dir(info.redis)) return make_response(jsonify({ 'cache': info.redis.ping(), - 'db': False + 'db': Database().connected }), 200)