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