Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

Commit

Permalink
fix(cron): handle sentry env in cron jobs (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
carolineBda authored Mar 24, 2022
1 parent 2eb3ce7 commit 3acb15c
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .socialgouv/environments/preprod/yaml/importData.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
labels:
app: mon-psy
spec:
schedule: "*/5 * * * *"
schedule: "0 */1 * * *"
jobTemplate:
spec:
template:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@faker-js/faker": "^6.0.0-alpha.6",
"@sentry/nextjs": "^6.17.9",
"@socialgouv/bootstrap.core": "^0.2.1",
"@socialgouv/matomo-next": "^1.2.2",
"@socialgouv/matomo-next": "^1.3.0",
"@types/sequelize": "^4.28.11",
"@typescript-eslint/eslint-plugin": "^5.11.0",
"axios": "^0.26.0",
Expand Down
4 changes: 2 additions & 2 deletions sentry.client.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as Sentry from "@sentry/nextjs";

const SENTRY_DSN = process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN;
const SENTRY_ENV = process.env.SENTRY_ENV || process.env.NEXT_PUBLIC_SENTRY_ENV;
const SENTRY_DSN = process.env.NEXT_PUBLIC_SENTRY_DSN;
const SENTRY_ENV = process.env.NEXT_PUBLIC_SENTRY_ENV;

Sentry.init({
dsn: SENTRY_DSN ?? "",
Expand Down
4 changes: 2 additions & 2 deletions sentry.server.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as Sentry from "@sentry/nextjs";

const SENTRY_DSN = process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN;
const SENTRY_ENV = process.env.SENTRY_ENV || process.env.NEXT_PUBLIC_SENTRY_ENV;
const SENTRY_DSN = process.env.NEXT_PUBLIC_SENTRY_DSN;
const SENTRY_ENV = process.env.NEXT_PUBLIC_SENTRY_ENV;

Sentry.init({
dsn: SENTRY_DSN ?? "",
Expand Down
6 changes: 3 additions & 3 deletions src/cron/demarchesSimplifiees.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as Sentry from "@sentry/nextjs";

import { models } from "../../src/db/models";
import { models } from "../db/models";
import {
getPsychologistList,
getPsychologistState,
} from "../../src/services/demarchesSimplifiees/import";
import { saveMany, updateState } from "../../src/services/psychologists";
} from "../services/demarchesSimplifiees/import";
import { saveMany, updateState } from "../services/psychologists";

export const importData = async (): Promise<void> => {
try {
Expand Down
2 changes: 2 additions & 0 deletions src/cron/launch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import * as demarchesSimplifiees from "./demarchesSimplifiees";

const runJob = async (job): Promise<void> => {
const SENTRY_DSN = process.env.NEXT_PUBLIC_SENTRY_DSN;
const SENTRY_ENV = process.env.NEXT_PUBLIC_SENTRY_ENV;

console.log(`Initializing Sentry with url: ${SENTRY_DSN}`);
Sentry.init({
dsn: SENTRY_DSN,
environment: SENTRY_ENV ?? "development",
});

await job();
Expand Down

0 comments on commit 3acb15c

Please sign in to comment.