Improve the loop
This commit is contained in:
@ -460,8 +460,10 @@ fn main() -> Result<()> {
|
||||
.execute("SELECT 0 WHERE 0;", named_params! {})
|
||||
.expect("Failed to initialize database");
|
||||
|
||||
thread::spawn(move || loop {
|
||||
thread::spawn(move || {
|
||||
let conn = get_connection(db_file.as_str());
|
||||
|
||||
loop {
|
||||
let mut stmt = conn.prepare("SELECT task_group_id, cidr FROM scan_tasks WHERE started_at IS NULL ORDER BY created_at ASC").unwrap();
|
||||
let mut rows = stmt.query(named_params! {}).unwrap();
|
||||
println!("Waiting for jobs");
|
||||
@ -508,6 +510,7 @@ fn main() -> Result<()> {
|
||||
|
||||
let two_hundred_millis = Duration::from_millis(500);
|
||||
thread::sleep(two_hundred_millis);
|
||||
}
|
||||
});
|
||||
|
||||
rouille::start_server(server_address, move |request| {
|
||||
|
Reference in New Issue
Block a user