Skip to content

Commit 108a572

Browse files
Merge pull request #347 from QuietMisdreavus/thread-names
use thread builders to give the daemon threads names
2 parents 09283ef + 63cbabc commit 108a572

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/utils/daemon.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ pub fn start_daemon() {
4646
}
4747

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

6262
thread::sleep(Duration::from_secs(60));
6363
}
64-
});
64+
}).unwrap();
6565

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

@@ -198,11 +198,11 @@ pub fn start_daemon() {
198198
*self = BuilderState::QueueInProgress(self.count() + 1);
199199
}
200200
}
201-
});
201+
}).unwrap();
202202

203203

204204
// update release activity everyday at 23:55
205-
thread::spawn(move || {
205+
thread::Builder::new().name("release activity updater".to_string()).spawn(move || {
206206
loop {
207207
thread::sleep(Duration::from_secs(60));
208208
let now = time::now();
@@ -213,30 +213,30 @@ pub fn start_daemon() {
213213
}
214214
}
215215
}
216-
});
216+
}).unwrap();
217217

218218

219219
// update search index every 3 hours
220-
thread::spawn(move || {
220+
thread::Builder::new().name("search index updater".to_string()).spawn(move || {
221221
loop {
222222
thread::sleep(Duration::from_secs(60 * 60 * 3));
223223
let conn = connect_db().expect("Failed to connect database");
224224
if let Err(e) = update_search_index(&conn) {
225225
error!("Failed to update search index: {}", e);
226226
}
227227
}
228-
});
228+
}).unwrap();
229229

230230

231231
// update github stats every 6 hours
232-
thread::spawn(move || {
232+
thread::Builder::new().name("github stat updater".to_string()).spawn(move || {
233233
loop {
234234
thread::sleep(Duration::from_secs(60 * 60 * 6));
235235
if let Err(e) = github_updater() {
236236
error!("Failed to update github fields: {}", e);
237237
}
238238
}
239-
});
239+
}).unwrap();
240240

241241
// TODO: update ssl certificate every 3 months
242242

0 commit comments

Comments
 (0)