mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-23 05:51:39 +00:00
Move all web pieces into WebConfig
This commit is contained in:
parent
d0f821add4
commit
81d232fac5
3 changed files with 8 additions and 5 deletions
|
|
@ -24,9 +24,11 @@ pub fn serve(project_path: &PathBuf, port: Option<u64>) {
|
||||||
let web_config = web::WebConfig {
|
let web_config = web::WebConfig {
|
||||||
port: port.unwrap_or(project.serve_port),
|
port: port.unwrap_or(project.serve_port),
|
||||||
server_id,
|
server_id,
|
||||||
|
project: project.clone(),
|
||||||
|
start_time: Instant::now(),
|
||||||
};
|
};
|
||||||
|
|
||||||
println!("Server listening on port {}", web_config.port);
|
println!("Server listening on port {}", web_config.port);
|
||||||
|
|
||||||
web::start(web_config, project.clone(), Instant::now());
|
web::start(web_config);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
use std::path::PathBuf;
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
use std::fs::{self, File};
|
use std::fs::{self, File};
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@ use web_util::json_response;
|
||||||
pub struct WebConfig {
|
pub struct WebConfig {
|
||||||
pub port: u64,
|
pub port: u64,
|
||||||
pub server_id: u64,
|
pub server_id: u64,
|
||||||
|
pub project: Project,
|
||||||
|
pub start_time: Instant,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
|
|
@ -22,7 +24,7 @@ struct ServerInfo<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Start the Rojo web server and park our current thread.
|
/// 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 address = format!("localhost:{}", config.port);
|
||||||
|
|
||||||
let server_id = config.server_id.to_string();
|
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.
|
// Get a summary of information about the server.
|
||||||
|
|
||||||
let current_time = {
|
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
|
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"),
|
server_version: env!("CARGO_PKG_VERSION"),
|
||||||
protocol_version: 1,
|
protocol_version: 1,
|
||||||
server_id: &server_id,
|
server_id: &server_id,
|
||||||
project: &project,
|
project: &config.project,
|
||||||
current_time,
|
current_time,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue