Skip to content

use thread builders to give the daemon threads names #347

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 6, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/utils/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub fn start_daemon() {
}

// check new crates every minute
thread::spawn(move || {
thread::Builder::new().name("crates.io reader".to_string()).spawn(move || {
// space this out to prevent it from clashing against the queue-builder thread on launch
thread::sleep(Duration::from_secs(30));
loop {
Expand All @@ -61,10 +61,10 @@ pub fn start_daemon() {

thread::sleep(Duration::from_secs(60));
}
});
}).unwrap();

// build new crates every minute
thread::spawn(move || {
thread::Builder::new().name("build queue reader".to_string()).spawn(move || {
let opts = opts();
let mut doc_builder = DocBuilder::new(opts);

Expand Down Expand Up @@ -198,11 +198,11 @@ pub fn start_daemon() {
*self = BuilderState::QueueInProgress(self.count() + 1);
}
}
});
}).unwrap();


// update release activity everyday at 23:55
thread::spawn(move || {
thread::Builder::new().name("release activity updater".to_string()).spawn(move || {
loop {
thread::sleep(Duration::from_secs(60));
let now = time::now();
Expand All @@ -213,30 +213,30 @@ pub fn start_daemon() {
}
}
}
});
}).unwrap();


// update search index every 3 hours
thread::spawn(move || {
thread::Builder::new().name("search index updater".to_string()).spawn(move || {
loop {
thread::sleep(Duration::from_secs(60 * 60 * 3));
let conn = connect_db().expect("Failed to connect database");
if let Err(e) = update_search_index(&conn) {
error!("Failed to update search index: {}", e);
}
}
});
}).unwrap();


// update github stats every 6 hours
thread::spawn(move || {
thread::Builder::new().name("github stat updater".to_string()).spawn(move || {
loop {
thread::sleep(Duration::from_secs(60 * 60 * 6));
if let Err(e) = github_updater() {
error!("Failed to update github fields: {}", e);
}
}
});
}).unwrap();

// TODO: update ssl certificate every 3 months

Expand Down