Improve the loop

This commit is contained in:
2024-06-26 19:13:37 +02:00
parent 7209aed6e1
commit e28b8cb945

View File

@ -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| {