Skip to content

Commit 33e304f

Browse files
committed
fix builder metrics, don't clone the context
1 parent 879b8e1 commit 33e304f

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/bin/cratesfyi.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,6 @@ enum DeleteSubcommand {
537537
},
538538
}
539539

540-
#[derive(Clone)]
541540
struct BinContext {
542541
build_queue: OnceCell<Arc<BuildQueue>>,
543542
storage: OnceCell<Arc<Storage>>,

src/utils/daemon.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,34 +95,36 @@ pub fn start_background_repository_stats_updater(context: &dyn Context) -> Resul
9595
Ok(())
9696
}
9797

98-
pub fn start_daemon<C: Context + Send + Clone + 'static>(
98+
pub fn start_daemon<C: Context + Send + Sync + 'static>(
9999
context: C,
100100
enable_registry_watcher: bool,
101101
) -> Result<(), Error> {
102+
let context = Arc::new(context);
103+
102104
// Start the web server before doing anything more expensive
103105
// Please check with an administrator before changing this (see #1172 for context).
104106
info!("Starting web server");
105107
let webserver_thread = thread::spawn({
106108
let context = context.clone();
107-
move || start_web_server(None, &context)
109+
move || start_web_server(None, &*context)
108110
});
109111

110112
if enable_registry_watcher {
111113
// check new crates every minute
112-
start_registry_watcher(&context)?;
114+
start_registry_watcher(&*context)?;
113115
}
114116

115117
// build new crates every minute
116118
let build_queue = context.build_queue()?;
117-
let rustwide_builder = RustwideBuilder::init(&context)?;
119+
let rustwide_builder = RustwideBuilder::init(&*context)?;
118120
thread::Builder::new()
119121
.name("build queue reader".to_string())
120122
.spawn(move || {
121123
queue_builder(rustwide_builder, build_queue).unwrap();
122124
})
123125
.unwrap();
124126

125-
start_background_repository_stats_updater(&context)?;
127+
start_background_repository_stats_updater(&*context)?;
126128

127129
// NOTE: if a error occurred earlier in `start_daemon`, the server will _not_ be joined -
128130
// instead it will get killed when the process exits.

0 commit comments

Comments
 (0)