Skip to content
This repository has been archived by the owner on Aug 13, 2024. It is now read-only.

Commit

Permalink
Refactor iron server to use passed in port number
Browse files Browse the repository at this point in the history
  • Loading branch information
ungn committed Mar 16, 2017
1 parent a9862d8 commit 0bfcea2
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions executor/src/executor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ pub mod commander;
#[cfg(test)]
mod tests;

use std::collections::VecDeque;
use std::net::SocketAddr;
use std::str::FromStr;
use std::sync::Mutex;
use std::sync::mpsc;
use std::sync::mpsc::{Sender, Receiver};
use std::collections::VecDeque;
use std::thread;
use std::thread::JoinHandle;
use iron::prelude::*;
Expand Down Expand Up @@ -64,6 +66,8 @@ pub fn start(args: Args) {
let storage = Persistence::new("/tmp", "test");
let dispatcher = Dispatcher::new(args.flag_max_jobs, args.flag_max_workers);
let commander = commands![FACTOTUM.to_string() => args.flag_factotum_bin];

let address = SocketAddr::from_str(&format!("0.0.0.0:{}", executor.port)).expect("Failed to parse socket address");

let (requests_channel, dispatcher_handle, cpupool) = trigger_worker_manager(dispatcher, commander).unwrap();

Expand All @@ -75,13 +79,13 @@ pub fn start(args: Args) {
submit: post "/submit" => responder::submit,
check: post "/check" => responder::check
);

let mut chain = Chain::new(router);
chain.link(State::<Server>::both(executor));
chain.link(State::<Storage>::both(storage));
chain.link(Read::<Updates>::both(Mutex::new(requests_channel)));

match Iron::new(chain).http("0.0.0.0:3000") {
match Iron::new(chain).http(address) {
Ok(listening) => {
let socket_addr = listening.socket;
let ip = socket_addr.ip();
Expand Down

0 comments on commit 0bfcea2

Please sign in to comment.