Skip to content

Commit 0bb8aee

Browse files
committed
Make getting the RUN_CRON environment flag a function
1 parent 8f1cf93 commit 0bb8aee

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

site/src/job_queue.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ use parking_lot::RwLock;
1212
use regex::Regex;
1313
use tokio::time::{self, Duration};
1414

15+
pub fn run_new_queue() -> bool {
16+
std::env::var("RUN_CRON")
17+
.ok()
18+
.and_then(|x| x.parse().ok())
19+
.unwrap_or(false)
20+
}
21+
1522
/// Store the latest master commits or do nothing if all of them are
1623
/// already in the database
1724
async fn create_benchmark_request_master_commits(

site/src/main.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use futures::future::FutureExt;
22
use parking_lot::RwLock;
3+
use site::job_queue::{cron_main, run_new_queue};
34
use site::load;
45
use std::env;
56
use std::sync::Arc;
@@ -33,10 +34,6 @@ async fn main() {
3334
.ok()
3435
.and_then(|x| x.parse().ok())
3536
.unwrap_or(30);
36-
let run_cron_job = env::var("RUN_CRON")
37-
.ok()
38-
.and_then(|x| x.parse().ok())
39-
.unwrap_or(false);
4037

4138
let fut = tokio::task::spawn_blocking(move || {
4239
tokio::task::spawn(async move {
@@ -62,9 +59,9 @@ async fn main() {
6259

6360
let server = site::server::start(ctxt.clone(), port).fuse();
6461

65-
if run_cron_job {
62+
if run_new_queue() {
6663
task::spawn(async move {
67-
site::job_queue::cron_main(ctxt.clone(), queue_update_interval_seconds).await;
64+
cron_main(ctxt.clone(), queue_update_interval_seconds).await;
6865
});
6966
}
7067

0 commit comments

Comments
 (0)