Skip to content

Commit 10d26cd

Browse files
committed
Update search index every 3 hours
1 parent efdf588 commit 10d26cd

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/utils/daemon.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use time;
1414
use DocBuilderOptions;
1515
use DocBuilder;
1616
use utils::{update_sources, update_release_activity};
17+
use db::{connect_db, update_search_index};
1718

1819

1920
const DAEMON_PID_FILE_PATH: &'static str = "/var/run/cratesfyi.pid";
@@ -108,6 +109,18 @@ pub fn start_daemon() {
108109
}
109110
});
110111

112+
113+
// update search index every 3 hours
114+
thread::spawn(move || {
115+
loop {
116+
thread::sleep(Duration::from_secs(60*60*3));
117+
let conn = connect_db().expect("Failed to connect database");
118+
if let Err(e) = update_search_index(&conn) {
119+
error!("Failed to update search index: {}", e);
120+
}
121+
}
122+
});
123+
111124
// TODO: update ssl certificate every 3 months
112125

113126
// at least start web server

0 commit comments

Comments
 (0)