File tree 2 files changed +10
-7
lines changed 2 files changed +10
-7
lines changed Original file line number Diff line number Diff line change 2
2
3
3
This is a simple Discord bot used to trigger WATO's infrastructure provisioning pipeline when a user joins the Discord server.
4
4
5
- ## Usage
5
+ ## Development
6
6
7
7
``` bash
8
8
docker build . -t discord-provisioner-bot
9
- docker run --rm -it -e DISCORD_TOKEN=< DISCORD_TOKEN> -e GITHUB_TOKEN=< GITHUB_TOKEN> -e SENTRY_DSN=< SENTRY_DSN> discord-provisioner-bot
9
+ docker run --rm -it -v $( pwd ) :/app - e DISCORD_TOKEN=< DISCORD_TOKEN> -e GITHUB_TOKEN=< GITHUB_TOKEN> -e SENTRY_DSN=< SENTRY_DSN> discord-provisioner-bot
10
10
```
11
11
12
12
## Deployment
13
13
14
- This bot is deployed to WATO's Kubernetes cluster. The deployment is managed in the internal [ infra-config] ( https://github.com/watonomous/infra-config ) repo.
14
+ This bot is deployed via in the internal [ infra-config] ( https://github.com/watonomous/infra-config ) repo.
Original file line number Diff line number Diff line change 6
6
import sentry_sdk
7
7
from aiohttp import web
8
8
from discord .ext import tasks
9
+ from sentry_sdk .integrations .asyncio import AsyncioIntegration
9
10
from sentry_sdk .integrations .logging import LoggingIntegration
10
11
from sentry_sdk .crons import monitor
11
12
from time import perf_counter , sleep
@@ -51,7 +52,7 @@ def sentry_traces_sampler(sampling_context):
51
52
52
53
sentry_sdk .init (
53
54
** sentry_config ,
54
- integrations = [sentry_logging ],
55
+ integrations = [sentry_logging , AsyncioIntegration () ],
55
56
56
57
# Set traces_sample_rate to 1.0 to capture 100%
57
58
# of transactions for performance monitoring.
@@ -118,12 +119,14 @@ async def health_endpoint(_request):
118
119
async def healthcheck_loop ():
119
120
logger .info (f'Healthcheck loop running. { client .is_closed ()= } ' )
120
121
start = perf_counter ()
121
- monitor_once ()
122
+ await monitor_once ()
122
123
stop = perf_counter ()
123
124
logger .info (f"Healthcheck loop completed in { stop - start :.2f} seconds" )
124
125
125
126
@monitor (monitor_slug = 'discord-provisioner-bot' )
126
- def monitor_once ():
127
- sleep (0.5 ) # space out the begin and end API calls
127
+ async def monitor_once ():
128
+ res = await health_endpoint (None )
129
+ if res .status != 200 :
130
+ raise Exception (f"Healthcheck failed with status { res .status } " )
128
131
129
132
client .run (os .environ ['DISCORD_TOKEN' ])
You can’t perform that action at this time.
0 commit comments