Fix build issue, add servePort project option

This commit is contained in:
Lucien Greathouse
2019-01-04 13:40:10 -08:00
parent 9cfeee0577
commit 64e2ef3d3b
4 changed files with 8 additions and 6 deletions

View File

@@ -65,7 +65,7 @@ fn main() {
let port = match sub_matches.value_of("port") {
Some(v) => match v.parse::<u16>() {
Ok(port) => port,
Ok(port) => Some(port),
Err(_) => {
error!("Invalid port {}", v);
process::exit(1);

View File

@@ -34,16 +34,16 @@ impl From<ProjectLoadFuzzyError> for ServeError {
pub fn serve(options: &ServeOptions) -> Result<(), ServeError> {
info!("Looking for project at {}", options.fuzzy_project_path.display());
let project = Project::load_fuzzy(&options.fuzzy_project_path)?;
let project = Arc::new(Project::load_fuzzy(&options.fuzzy_project_path)?);
info!("Found project at {}", project.file_location.display());
info!("Using project {:#?}", project);
let session = Arc::new(Session::new(project).unwrap());
let session = Arc::new(Session::new(Arc::clone(&project)).unwrap());
let server = Server::new(Arc::clone(&session));
let port = options.port
// .or(project.serve_port)
.or(project.serve_port)
.unwrap_or(DEFAULT_PORT);
println!("Rojo server listening on port {}", port);

View File

@@ -77,6 +77,7 @@ impl SourceProjectNode {
struct SourceProject {
name: String,
tree: SourceProjectNode,
serve_port: Option<u16>,
}
impl SourceProject {
@@ -86,6 +87,7 @@ impl SourceProject {
Project {
name: self.name,
tree,
serve_port: self.serve_port,
file_location: PathBuf::from(project_file_location),
}
}
@@ -169,6 +171,7 @@ pub struct SyncPointProjectNode {
pub struct Project {
pub name: String,
pub tree: ProjectNode,
pub serve_port: Option<u16>,
pub file_location: PathBuf,
}

View File

@@ -23,14 +23,13 @@ pub struct Session {
}
impl Session {
pub fn new(project: Project) -> io::Result<Session> {
pub fn new(project: Arc<Project>) -> io::Result<Session> {
let imfs = {
let mut imfs = Imfs::new();
imfs.add_roots_from_project(&project)?;
Arc::new(Mutex::new(imfs))
};
let project = Arc::new(project);
let message_queue = Arc::new(MessageQueue::new());
let rbx_session = Arc::new(Mutex::new(RbxSession::new(