diff --git a/server/src/commands/serve.rs b/server/src/commands/serve.rs index 3a2a4582..f6fed859 100644 --- a/server/src/commands/serve.rs +++ b/server/src/commands/serve.rs @@ -24,9 +24,11 @@ pub fn serve(project_path: &PathBuf, port: Option) { let web_config = web::WebConfig { port: port.unwrap_or(project.serve_port), server_id, + project: project.clone(), + start_time: Instant::now(), }; println!("Server listening on port {}", web_config.port); - web::start(web_config, project.clone(), Instant::now()); + web::start(web_config); } diff --git a/server/src/rbx_session.rs b/server/src/rbx_session.rs index 4067b680..9ac1ee4c 100644 --- a/server/src/rbx_session.rs +++ b/server/src/rbx_session.rs @@ -1,4 +1,3 @@ -use std::path::PathBuf; use std::collections::HashMap; use std::io::Read; use std::fs::{self, File}; diff --git a/server/src/web.rs b/server/src/web.rs index f74cbeba..73b4cb75 100644 --- a/server/src/web.rs +++ b/server/src/web.rs @@ -9,6 +9,8 @@ use web_util::json_response; pub struct WebConfig { pub port: u64, pub server_id: u64, + pub project: Project, + pub start_time: Instant, } #[derive(Debug, Serialize)] @@ -22,7 +24,7 @@ struct ServerInfo<'a> { } /// Start the Rojo web server and park our current thread. -pub fn start(config: WebConfig, project: Project, start_time: Instant) { +pub fn start(config: WebConfig) { let address = format!("localhost:{}", config.port); let server_id = config.server_id.to_string(); @@ -33,7 +35,7 @@ pub fn start(config: WebConfig, project: Project, start_time: Instant) { // Get a summary of information about the server. let current_time = { - let elapsed = start_time.elapsed(); + let elapsed = config.start_time.elapsed(); elapsed.as_secs() as f64 + elapsed.subsec_nanos() as f64 / 1_000_000_000.0 }; @@ -42,7 +44,7 @@ pub fn start(config: WebConfig, project: Project, start_time: Instant) { server_version: env!("CARGO_PKG_VERSION"), protocol_version: 1, server_id: &server_id, - project: &project, + project: &config.project, current_time, }) },