From 6d6622b825cc7c11458cb863e0f1aa2875705cd6 Mon Sep 17 00:00:00 2001 From: emmatveev Date: Fri, 22 Nov 2024 00:43:00 +0300 Subject: [PATCH 1/2] net --- .deploy/deploy-dev.yaml | 3 +++ .deploy/deploy-prod.yaml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/.deploy/deploy-dev.yaml b/.deploy/deploy-dev.yaml index e1d43a9..746d234 100644 --- a/.deploy/deploy-dev.yaml +++ b/.deploy/deploy-dev.yaml @@ -6,6 +6,7 @@ services: image: mathwave/sprint-repo:queues networks: - common-infra-nginx + - queues environment: MONGO_HOST: "mongo.develop.sprinthub.ru" MONGO_PASSWORD: $MONGO_PASSWORD_DEV @@ -21,3 +22,5 @@ services: networks: common-infra-nginx: external: true + queues: + external: true diff --git a/.deploy/deploy-prod.yaml b/.deploy/deploy-prod.yaml index 6ad74f6..a70f034 100644 --- a/.deploy/deploy-prod.yaml +++ b/.deploy/deploy-prod.yaml @@ -6,6 +6,7 @@ services: image: mathwave/sprint-repo:queues networks: - common-infra-nginx + - queues environment: MONGO_HOST: "mongo.sprinthub.ru" MONGO_PASSWORD: $MONGO_PASSWORD_PROD @@ -21,3 +22,5 @@ services: networks: common-infra-nginx: external: true + queues: + external: true From 4fb1043a631c5b5f8c976a443a6d1c8594302c11 Mon Sep 17 00:00:00 2001 From: emmatveev Date: Fri, 22 Nov 2024 01:00:40 +0300 Subject: [PATCH 2/2] fix --- .deploy/deploy-dev.yaml | 17 ++++++++++++++++- .deploy/deploy-prod.yaml | 18 +++++++++++++++++- main.py | 16 ++-------------- 3 files changed, 35 insertions(+), 16 deletions(-) diff --git a/.deploy/deploy-dev.yaml b/.deploy/deploy-dev.yaml index 746d234..f53da09 100644 --- a/.deploy/deploy-dev.yaml +++ b/.deploy/deploy-dev.yaml @@ -6,7 +6,6 @@ services: image: mathwave/sprint-repo:queues networks: - common-infra-nginx - - queues environment: MONGO_HOST: "mongo.develop.sprinthub.ru" MONGO_PASSWORD: $MONGO_PASSWORD_DEV @@ -19,6 +18,22 @@ services: parallelism: 1 order: start-first + queues: + image: mathwave/sprint-repo:queues + networks: + - queues + environment: + MONGO_HOST: "mongo.develop.sprinthub.ru" + MONGO_PASSWORD: $MONGO_PASSWORD_DEV + NEW: "true" + deploy: + mode: replicated + restart_policy: + condition: any + update_config: + parallelism: 1 + order: start-first + networks: common-infra-nginx: external: true diff --git a/.deploy/deploy-prod.yaml b/.deploy/deploy-prod.yaml index a70f034..f5d3c0d 100644 --- a/.deploy/deploy-prod.yaml +++ b/.deploy/deploy-prod.yaml @@ -6,7 +6,6 @@ services: image: mathwave/sprint-repo:queues networks: - common-infra-nginx - - queues environment: MONGO_HOST: "mongo.sprinthub.ru" MONGO_PASSWORD: $MONGO_PASSWORD_PROD @@ -19,6 +18,23 @@ services: parallelism: 1 order: start-first + queues: + image: mathwave/sprint-repo:queues + networks: + - common-infra-nginx + - queues + environment: + MONGO_HOST: "mongo.sprinthub.ru" + MONGO_PASSWORD: $MONGO_PASSWORD_PROD + NEW: "true" + deploy: + mode: replicated + restart_policy: + condition: any + update_config: + parallelism: 1 + order: start-first + networks: common-infra-nginx: external: true diff --git a/main.py b/main.py index 8c17be6..5fd4b5d 100644 --- a/main.py +++ b/main.py @@ -8,23 +8,9 @@ from app.routers import finish from app.storage import mongo -from fastapi import responses - - -QUEUES_TOKEN = os.getenv('QUEUES_TOKEN') app = fastapi.FastAPI() - -@app.middleware('http') -async def check_token(request: fastapi.Request, call_next): - if QUEUES_TOKEN: - token = request.headers.get('X-Queues-Token') - if not token or token != QUEUES_TOKEN: - return responses.JSONResponse(status_code=403, content={'message': 'token is not provided or incorrect'}) - return await call_next(request) - - app.include_router(take.router) app.include_router(put.router) app.include_router(finish.router) @@ -33,4 +19,6 @@ mongo.create_indexes() if __name__ == '__main__': + if os.getenv('NEW') == 'true': + uvicorn.run(app, host="0.0.0.0", port=1239) uvicorn.run(app, host="0.0.0.0", port=1238)