@@ -85,35 +85,23 @@ fn main() -> anyhow::Result<()> {
85
85
86
86
let environment = Arc :: new ( environment) ;
87
87
88
- let build_runner = || {
89
- let connection_pool = r2d2:: Pool :: builder ( )
90
- . max_size ( 10 )
91
- . min_idle ( Some ( 0 ) )
92
- . build_unchecked ( ConnectionManager :: new ( & db_url) ) ;
88
+ let connection_pool = r2d2:: Pool :: builder ( )
89
+ . max_size ( 10 )
90
+ . min_idle ( Some ( 0 ) )
91
+ . build_unchecked ( ConnectionManager :: new ( & db_url) ) ;
93
92
94
- let connection_pool = DieselPool :: new_background_worker ( connection_pool) ;
93
+ let connection_pool = DieselPool :: new_background_worker ( connection_pool) ;
95
94
96
- Runner :: new ( connection_pool, environment. clone ( ) )
97
- . num_workers ( 5 )
98
- . job_start_timeout ( Duration :: from_secs ( job_start_timeout) )
99
- . register_crates_io_job_types ( )
100
- } ;
101
-
102
- let mut runner = build_runner ( ) ;
95
+ let runner = Runner :: new ( connection_pool, environment. clone ( ) )
96
+ . num_workers ( 5 )
97
+ . job_start_timeout ( Duration :: from_secs ( job_start_timeout) )
98
+ . register_crates_io_job_types ( ) ;
103
99
104
100
info ! ( "Runner booted, running jobs" ) ;
105
101
106
- let mut failure_count = 0 ;
107
-
108
102
loop {
109
- if let Err ( e) = runner. run_all_pending_jobs ( ) {
110
- failure_count += 1 ;
111
- if failure_count < 5 {
112
- warn ! ( ?failure_count, err = ?e, "Error running jobs -- retrying" ) ;
113
- runner = build_runner ( ) ;
114
- } else {
115
- panic ! ( "Failed to begin running jobs 5 times. Restarting the process" ) ;
116
- }
103
+ if let Err ( err) = runner. run_all_pending_jobs ( ) {
104
+ warn ! ( %err, "Failed to run background jobs" ) ;
117
105
}
118
106
sleep ( Duration :: from_secs ( 1 ) ) ;
119
107
}
0 commit comments