Skip to content

Commit 3a6a290

Browse files
authored
Merge pull request #2039 from Kobzol/skip-workqueue
Add possibility to skip workqueue loading
2 parents 45b12cb + 246129c commit 3a6a290

File tree

2 files changed

+30
-12
lines changed

2 files changed

+30
-12
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ The general overview of what you will need to do:
5050
6. Add a `triagebot.toml` file to the main branch of your GitHub repo with whichever services you want to try out.
5151
7. Try interacting with your repo, such as issuing `@rustbot` commands or interacting with PRs and issues (depending on which services you enabled in `triagebot.toml`). Watch the logs from the server to see what's going on.
5252

53+
#### Skipping workqueue loading
54+
55+
When triagebot starts, it eagerly loads the pull request workqueue for the `rust-lang/rust` repository, which can take up ~10-15 seconds. To disable this, for faster local experiments, pass the `SKIP_WORKQUEUE=1` environment variable to triagebot.
56+
5357
### Configure a database
5458

5559
To use Postgres, you will need to install it and configure it:

src/main.rs

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -255,23 +255,37 @@ async fn run_server(addr: SocketAddr) -> anyhow::Result<()> {
255255
.build()
256256
.expect("Failed to build octograb.");
257257

258+
// Loading the workqueue takes ~10-15s, and it's annoying for local rebuilds.
259+
// Allow users to opt out of it.
260+
let skip_loading_workqueue = env::var("SKIP_WORKQUEUE")
261+
.ok()
262+
.map(|v| v == "1")
263+
.unwrap_or(false);
264+
258265
// Load the initial workqueue state from GitHub
259266
// In case this fails, we do not want to block triagebot, instead
260267
// we use an empty workqueue and let it be updated later through
261268
// webhooks and the `PullRequestAssignmentUpdate` cron job.
262-
tracing::info!("Loading reviewer workqueue for rust-lang/rust");
263-
let workqueue = match tokio::time::timeout(Duration::from_secs(60), load_workqueue(&oc)).await {
264-
Ok(Ok(workqueue)) => workqueue,
265-
Ok(Err(error)) => {
266-
tracing::error!("Cannot load initial workqueue: {error:?}");
267-
ReviewerWorkqueue::default()
268-
}
269-
Err(_) => {
270-
tracing::error!("Cannot load initial workqueue, timeouted after a minute");
271-
ReviewerWorkqueue::default()
272-
}
269+
let workqueue = if skip_loading_workqueue {
270+
tracing::warn!("Skipping workqueue loading");
271+
ReviewerWorkqueue::default()
272+
} else {
273+
tracing::info!("Loading reviewer workqueue for rust-lang/rust");
274+
let workqueue =
275+
match tokio::time::timeout(Duration::from_secs(60), load_workqueue(&oc)).await {
276+
Ok(Ok(workqueue)) => workqueue,
277+
Ok(Err(error)) => {
278+
tracing::error!("Cannot load initial workqueue: {error:?}");
279+
ReviewerWorkqueue::default()
280+
}
281+
Err(_) => {
282+
tracing::error!("Cannot load initial workqueue, timeouted after a minute");
283+
ReviewerWorkqueue::default()
284+
}
285+
};
286+
tracing::info!("Workqueue loaded");
287+
workqueue
273288
};
274-
tracing::info!("Workqueue loaded");
275289

276290
// Only run the migrations after the workqueue has been loaded, immediately
277291
// before starting the HTTP server.

0 commit comments

Comments
 (0)