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;
44pub mod api;
55pub mod github;
66pub mod load;
7+ pub mod queue_jobs;
78pub mod server;
89
910mod average;
1011mod benchmark_metadata;
1112mod comparison;
12- mod queue_jobs;
1313mod request_handlers;
1414mod resources;
1515mod selector;
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ use parking_lot::RwLock;
33use site:: load;
44use std:: env;
55use std:: sync:: Arc ;
6+ use tokio:: task;
67
78#[ cfg( unix) ]
89#[ global_allocator]
@@ -28,6 +29,15 @@ async fn main() {
2829 . ok ( )
2930 . and_then ( |x| x. parse ( ) . ok ( ) )
3031 . 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+
3141 let fut = tokio:: task:: spawn_blocking ( move || {
3242 tokio:: task:: spawn ( async move {
3343 let res = Arc :: new ( load:: SiteCtxt :: from_db_url ( & db_url) . await . unwrap ( ) ) ;
@@ -50,7 +60,14 @@ async fn main() {
5060 . fuse ( ) ;
5161 println ! ( "Starting server with port={:?}" , port) ;
5262
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+
5471 futures:: pin_mut!( server) ;
5572 futures:: pin_mut!( fut) ;
5673 loop {
You can’t perform that action at this time.
0 commit comments