Skip to content

Commit e759bf5

Browse files
jyn514Joshua Nelson
authored and
Joshua Nelson
committed
Start the webserver before trying to download the crates-build-env image
1 parent f718301 commit e759bf5

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

src/bin/cratesfyi.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ impl CommandLine {
116116
socket_addr,
117117
reload_templates,
118118
} => {
119-
Server::start(Some(&socket_addr), reload_templates, &ctx)?;
119+
// Blocks indefinitely
120+
let _ = Server::start(Some(&socket_addr), reload_templates, &ctx)?;
120121
}
121122
Self::Daemon {
122123
foreground,

src/utils/daemon.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ fn start_registry_watcher(context: &dyn Context) -> Result<(), Error> {
5151
}
5252

5353
pub fn start_daemon(context: &dyn Context, enable_registry_watcher: bool) -> Result<(), Error> {
54+
// Start the web server before doing anything more expensive
55+
// Please check with an administrator before changing this (see #1172 for context).
56+
info!("Starting web server");
57+
let _server = crate::Server::start(None, false, context)?;
58+
5459
let config = context.config()?;
5560

5661
if enable_registry_watcher {
@@ -98,10 +103,7 @@ pub fn start_daemon(context: &dyn Context, enable_registry_watcher: bool) -> Res
98103
},
99104
)?;
100105

101-
// at least start web server
102-
info!("Starting web server");
103-
104-
crate::Server::start(None, false, context)?;
106+
// Never returns; `server` blocks indefinitely when dropped
105107
Ok(())
106108
}
107109

src/web/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ fn render_markdown(text: &str) -> String {
401401
markdown_to_html(text, &options)
402402
}
403403

404+
#[must_use = "`Server` blocks indefinitely when dropped"]
404405
pub struct Server {
405406
inner: Listening,
406407
}

0 commit comments

Comments
 (0)