-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ajout wrapper cron sentry (production) (#198)
* chore: upgrade version github actions (cd.yml) (#201) downgrade python github action to v4 fix cd * feat: ajoute un wrapper pour capturer les erreurs des crons sur sentry * feat: add sentry-cli * fix: indentation * fix: sentry-cli install * fix: sentry_wrapper_cron path * fix: sentry wrapper fonctionnel
- Loading branch information
Showing
4 changed files
with
50 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
- name: Install @sentry/cli using npm | ||
community.general.npm: | ||
name: '@sentry/cli' | ||
global: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/bash | ||
|
||
# This script is executing the command passed as 2nd argument | ||
# and send an event to Sentry if the command fails. | ||
# The .env file path is passed as the first argument. | ||
|
||
|
||
ENV_FILE_PATH=$1 | ||
shift # Remove the first argument | ||
if [ -z "$ENV_FILE_PATH" ]; then | ||
echo "Error: .env file path is missing" | ||
exit 1 | ||
fi | ||
source $ENV_FILE_PATH | ||
|
||
if [ -z "$SENTRY_CRON_DSN" ]; then | ||
echo "Error: SENTRY_CRON_DSN is not set in .env file" | ||
exit 1 | ||
fi | ||
|
||
echo "SENTRY_CRON_DSN is set to: $SENTRY_CRON_DSN" | ||
|
||
# The wrapped command is executed and the result status is stored | ||
COMMAND="$@" | ||
OUTPUT=$(eval "$COMMAND" 2>&1) | ||
STATUS=$? | ||
|
||
if [ $STATUS -ne 0 ]; then | ||
echo "Cron job failed: $COMMAND" | ||
echo "Error output: $OUTPUT" | ||
SENTRY_DSN="$SENTRY_CRON_DSN" sentry-cli send-event -m "Cron job failed: $COMMAND | Error: $OUTPUT" | ||
fi | ||
|
||
exit $STATUS |