File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -4,12 +4,12 @@ extern crate itertools;
4
4
pub mod api;
5
5
pub mod github;
6
6
pub mod load;
7
+ pub mod queue_jobs;
7
8
pub mod server;
8
9
9
10
mod average;
10
11
mod benchmark_metadata;
11
12
mod comparison;
12
- mod queue_jobs;
13
13
mod request_handlers;
14
14
mod resources;
15
15
mod selector;
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ use parking_lot::RwLock;
3
3
use site:: load;
4
4
use std:: env;
5
5
use std:: sync:: Arc ;
6
+ use tokio:: task;
6
7
7
8
#[ cfg( unix) ]
8
9
#[ global_allocator]
@@ -28,6 +29,15 @@ async fn main() {
28
29
. ok ( )
29
30
. and_then ( |x| x. parse ( ) . ok ( ) )
30
31
. unwrap_or ( 2346 ) ;
32
+ let queue_update_interval_seconds = env:: var ( "QUEUE_UPDATE_INTERVAL_SECONDS" )
33
+ . ok ( )
34
+ . and_then ( |x| x. parse ( ) . ok ( ) )
35
+ . 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 ) ;
40
+
31
41
let fut = tokio:: task:: spawn_blocking ( move || {
32
42
tokio:: task:: spawn ( async move {
33
43
let res = Arc :: new ( load:: SiteCtxt :: from_db_url ( & db_url) . await . unwrap ( ) ) ;
@@ -50,7 +60,14 @@ async fn main() {
50
60
. fuse ( ) ;
51
61
println ! ( "Starting server with port={:?}" , port) ;
52
62
53
- let server = site:: server:: start ( ctxt, port) . fuse ( ) ;
63
+ let server = site:: server:: start ( ctxt. clone ( ) , port) . fuse ( ) ;
64
+
65
+ if run_cron_job {
66
+ task:: spawn ( async move {
67
+ site:: queue_jobs:: cron_enqueue_jobs ( ctxt. clone ( ) , queue_update_interval_seconds) . await ;
68
+ } ) ;
69
+ }
70
+
54
71
futures:: pin_mut!( server) ;
55
72
futures:: pin_mut!( fut) ;
56
73
loop {
You can’t perform that action at this time.
0 commit comments