env bugfix

This commit is contained in:
crflynn
2018-04-22 18:58:46 -04:00
parent 639a1febc2
commit 5161e5cd09
5 changed files with 12 additions and 7 deletions

1
.gitignore vendored
View File

@@ -1,6 +1,7 @@
# credentials
secret.*
env_vars*
*.env
# mac osx
.DS_Store

View File

@@ -2,6 +2,7 @@ FROM python:3.6-slim
ADD requirements.txt requirements.txt
RUN pip install -r requirements.txt
ADD . .
EXPOSE 5000

View File

@@ -11,9 +11,8 @@ services:
flask:
build: .
restart: always
environment:
- FLASK_APP=pypistats/run.py
- ENV=prod
env_file:
- pypistats/secret/prod.env
command: 'flask run --host=0.0.0.0'
ports:
- '5000:5000'
@@ -21,6 +20,8 @@ services:
celery:
build: .
restart: always
env_file:
- pypistats/secret/prod.env
command: 'celery -A pypistats.run.celery worker -l info'
user: nobody
depends_on:
@@ -29,6 +30,8 @@ services:
beat:
build: .
restart: always
command: 'celery beat -A pypistats.run.celery -l info'
env_file:
- pypistats/secret/prod.env
command: 'celery beat -A pypistats.run.celery -l info --pidfile='
depends_on:
- redis

View File

@@ -22,7 +22,6 @@ def create_app(config_object=DevConfig):
def create_celery(app):
"""Create a celery object."""
celery = Celery(app.import_name, broker=app.config["CELERY_BROKER_URL"])
celery.conf.update(app.config)
celery.config_from_object(app.config)
class ContextTask(Task):

View File

@@ -11,12 +11,13 @@ from pypistats.settings import configs
# change this for migrations
env = os.environ.get("ENV", "dev")
env = os.environ.get("ENV", "prod")
print(env)
app = create_app(configs[env])
celery = create_celery(app)
app.logger.info(f"Environment: {env}")
@app.before_request
def before_request():