From a3098fef22e20245963c030a1f41feaf59ee3eb4 Mon Sep 17 00:00:00 2001 From: belajarqywok Date: Mon, 13 Nov 2023 10:24:11 +0700 Subject: [PATCH] Update: Database pooling and CI/CD pipeline --- .github/workflows/development.yaml | 2 -- .github/workflows/production.yaml | 17 ++++++++++------- src/configurations/databases/postgresql.py | 10 +++++++++- .../__pycache__/nlp_service.cpython-39.pyc | Bin 1014 -> 1014 bytes .../__pycache__/nlp_utils.cpython-39.pyc | Bin 1924 -> 1924 bytes 5 files changed, 19 insertions(+), 10 deletions(-) diff --git a/.github/workflows/development.yaml b/.github/workflows/development.yaml index 4f57e3e..0666ff1 100644 --- a/.github/workflows/development.yaml +++ b/.github/workflows/development.yaml @@ -39,7 +39,6 @@ jobs: name: Performance and Load Testing runs-on: ubuntu-latest environment: testing - needs: unit_testing steps: - name: Checkout @@ -109,7 +108,6 @@ jobs: name: Vulnerability Scanning runs-on: ubuntu-latest environment: testing - needs: performance_and_load_testing steps: - name: Checkout diff --git a/.github/workflows/production.yaml b/.github/workflows/production.yaml index dc6704d..302e233 100644 --- a/.github/workflows/production.yaml +++ b/.github/workflows/production.yaml @@ -39,7 +39,7 @@ jobs: needs: testing env: - version: '1.0' + version: latest service: ml-service region: asia-southeast2 project_id: ${{ secrets.GOOGLE_PROJECT }} @@ -110,7 +110,7 @@ jobs: id: deploy-cloud-run with: service: ml-service - image: gcr.io/${{ secrets.GOOGLE_PROJECT }}/ml-service:1.0 + image: gcr.io/${{ secrets.GOOGLE_PROJECT }}/ml-service:latest region: asia-southeast2 flags: | --cpu=4 @@ -118,17 +118,17 @@ jobs: --cpu-boost --memory=4Gi --timeout=800 - --concurrency=80 + --concurrency=80 --min-instances=0 --max-instances=13 --project=${{ secrets.GOOGLE_PROJECT }} --allow-unauthenticated --vpc-egress=private-ranges-only - --vpc-connector=projects/${{ secrets.GOOGLE_PROJECT }}/locations/asia-southeast2/connectors/ml-service-connector + --vpc-connector=projects/${{ secrets.GOOGLE_PROJECT }}/locations/asia-southeast2/connectors/ml-service-connector --service-account=${{ secrets.CLOUD_RUN_SA }} env_vars: | - VERSION=$version + VERSION=v1 JWT_ACCESS_TOKEN_SECRET=${{ secrets.JWT_ACCESS_TOKEN_SECRET }} JWT_REFRESH_TOKEN_SECRET=${{ secrets.JWT_REFRESH_TOKEN_SECRET }} JWT_ALGORITHM=${{ secrets.JWT_ALGORITHM }} @@ -140,5 +140,8 @@ jobs: POSTGRES_PASS=${{ secrets.POSTGRES_PASS }} POSTGRES_DB=${{ secrets.POSTGRES_DB }} - - name: 'Cloud Run URL Output' - run: 'echo "${{ steps.deploy-cloud-run.outputs.url }}"' + - name: Cloud Run URL Output + run: echo "${{ steps.deploy-cloud-run.outputs.url }}" + + - name: Send Discord Notification + run: echo "send notification" diff --git a/src/configurations/databases/postgresql.py b/src/configurations/databases/postgresql.py index 056a21e..56bb7ec 100644 --- a/src/configurations/databases/postgresql.py +++ b/src/configurations/databases/postgresql.py @@ -12,6 +12,10 @@ class Engines: def __init__(self) -> None: # IP Engine self.ip_engine: Engine = create_engine( + pool_size = 10, + pool_timeout = 5, + max_overflow = 10, + pool_recycle = 3600, url = ( f'postgresql+psycopg2://' + f'{os.getenv("POSTGRES_USER")}:{os.getenv("POSTGRES_PASS")}' + @@ -22,7 +26,11 @@ def __init__(self) -> None: # UNIX Socket Engine self.unix_sock_engine: Engine = create_engine( - engine.url.URL.create( + pool_size = 10, + pool_timeout = 5, + max_overflow = 10, + pool_recycle = 3600, + url = engine.url.URL.create( drivername = 'postgresql+psycopg2', username = f'{os.getenv("POSTGRES_USER")}', password = f'{os.getenv("POSTGRES_PASS")}', diff --git a/src/services/ml_services/__pycache__/nlp_service.cpython-39.pyc b/src/services/ml_services/__pycache__/nlp_service.cpython-39.pyc index 57b127149557ba2fd91be62b7637c7c9e4f6e7fc..5ae3035fa4dc650a9156629d1f7b7e710101b3db 100644 GIT binary patch delta 20 acmeyy{*9eGk(ZZ?0SNNv1Z?Df%?toK$pw%A delta 20 acmeyy{*9eGk(ZZ?0SJy2yKUrt%?toM0tK`H diff --git a/src/utilities/__pycache__/nlp_utils.cpython-39.pyc b/src/utilities/__pycache__/nlp_utils.cpython-39.pyc index 4c6a63af69dbda1d565ccaa8481c24788e28c1fe..cff74033018074f5afe680a97977e95a71f0af7e 100644 GIT binary patch delta 20 ZcmZqSZ{g=o