Skip to content

Commit

Permalink
fix: data fetcher force close connections on shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
vasyl-ivanchuk committed Feb 28, 2024
1 parent 18925c4 commit 7fece3c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 91 deletions.
92 changes: 2 additions & 90 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- main
- '[0-9]+.*'
- beta

jobs:
createReleaseVersion:
Expand Down Expand Up @@ -59,7 +60,7 @@ jobs:
permissions:
contents: read
needs: createReleaseVersion
if: ${{ github.ref == 'refs/heads/main' && needs.createReleaseVersion.outputs.releaseVersion != '' }}
if: ${{ needs.createReleaseVersion.outputs.releaseVersion != '' }}
steps:
- uses: actions/checkout@v3

Expand All @@ -83,31 +84,12 @@ jobs:
run: |
gcloud auth configure-docker us-docker.pkg.dev -q
- name: Build and push Docker image for API
uses: docker/build-push-action@v4
with:
push: true
tags: |
"matterlabs/block-explorer-api:latest"
"matterlabs/block-explorer-api:v${{ needs.createReleaseVersion.outputs.releaseVersion }}"
"matterlabs/block-explorer-api:${{ steps.setVersionForFlux.outputs.imageTag }}"
"us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/block-explorer-api:latest"
"us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/block-explorer-api:v${{ needs.createReleaseVersion.outputs.releaseVersion }}"
"us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/block-explorer-api:${{ steps.setVersionForFlux.outputs.imageTag }}"
file: packages/api/Dockerfile
no-cache: true

- name: Build and push Docker image for Worker
uses: docker/build-push-action@v4
with:
push: true
tags: |
"matterlabs/block-explorer-worker:latest"
"matterlabs/block-explorer-worker:v${{ needs.createReleaseVersion.outputs.releaseVersion }}"
"matterlabs/block-explorer-worker:${{ steps.setVersionForFlux.outputs.imageTag }}"
"us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/block-explorer-worker:latest"
"us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/block-explorer-worker:v${{ needs.createReleaseVersion.outputs.releaseVersion }}"
"us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/block-explorer-worker:${{ steps.setVersionForFlux.outputs.imageTag }}"
file: packages/worker/Dockerfile
no-cache: true

Expand All @@ -116,76 +98,6 @@ jobs:
with:
push: true
tags: |
"matterlabs/block-explorer-data-fetcher:latest"
"matterlabs/block-explorer-data-fetcher:v${{ needs.createReleaseVersion.outputs.releaseVersion }}"
"matterlabs/block-explorer-data-fetcher:${{ steps.setVersionForFlux.outputs.imageTag }}"
"us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/block-explorer-data-fetcher:latest"
"us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/block-explorer-data-fetcher:v${{ needs.createReleaseVersion.outputs.releaseVersion }}"
"us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/block-explorer-data-fetcher:${{ steps.setVersionForFlux.outputs.imageTag }}"
file: packages/data-fetcher/Dockerfile
no-cache: true

- name: Build and push Docker image for App
uses: docker/build-push-action@v4
with:
push: true
tags: |
"matterlabs/block-explorer-app:latest"
"matterlabs/block-explorer-app:v${{ needs.createReleaseVersion.outputs.releaseVersion }}"
"matterlabs/block-explorer-app:${{ steps.setVersionForFlux.outputs.imageTag }}"
"us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/block-explorer-app:latest"
"us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/block-explorer-app:v${{ needs.createReleaseVersion.outputs.releaseVersion }}"
"us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/block-explorer-app:${{ steps.setVersionForFlux.outputs.imageTag }}"
file: packages/app/Dockerfile
no-cache: true

deployFrontendToStaging:
name: Deploy Block Explorer frontend to staging
runs-on: ubuntu-latest
permissions:
contents: read
needs: createReleaseVersion
if: ${{ github.ref == 'refs/heads/main' && needs.createReleaseVersion.outputs.releaseVersion != '' }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Download Dist package
uses: dsaltares/fetch-gh-release-asset@master
with:
version: "tags/v${{ needs.createReleaseVersion.outputs.releaseVersion }}"
file: "dist.zip"
target: "dist.zip"
token: ${{ secrets.GITHUB_TOKEN }}

- name: Unzip Dist package
run: |
unzip dist.zip -d packages/app
- name: Update config
run: |
echo "window[\"##runtimeConfig\"] = { appEnvironment: \"staging\", sentryDSN: \"${{ vars.SENTRY_DSN }}\" };" > packages/app/dist/config.js
- name: Download Storybook package
uses: dsaltares/fetch-gh-release-asset@master
with:
version: "tags/v${{ needs.createReleaseVersion.outputs.releaseVersion }}"
file: "storybook-static.zip"
target: "storybook-static.zip"
token: ${{ secrets.GITHUB_TOKEN }}

- name: Unzip Storybook package
run: |
unzip storybook-static.zip -d packages/app
- name: Deploy
uses: matter-labs/action-hosting-deploy@main
id: deploy
with:
repoToken: "${{ secrets.GITHUB_TOKEN }}"
firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_STAGING_SCAN_V2 }}"
projectId: staging-scan-v2
channelID: live
entryPoint: ./packages/app
2 changes: 1 addition & 1 deletion packages/data-fetcher/src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const loggerFormatters: Logform.Format[] = [
format: "DD/MM/YYYY HH:mm:ss.SSS",
}),
format.ms(),
utilities.format.nestLike("Worker", {}),
utilities.format.nestLike("DataFetcher", {}),
];

if (NODE_ENV === "production") {
Expand Down
1 change: 1 addition & 0 deletions packages/data-fetcher/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ async function bootstrap() {

const app = await NestFactory.create(AppModule, {
logger,
forceCloseConnections: true,
});

const configService = app.get(ConfigService);
Expand Down

0 comments on commit 7fece3c

Please sign in to comment.