Skip to content

Commit

Permalink
Merge pull request #28 from jjcomer/master
Browse files Browse the repository at this point in the history
Add address binding and improve repo finding
  • Loading branch information
jonathanmorley authored Aug 30, 2019
2 parents 067cdb1 + 8c53e2d commit 1832600
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ pub fn reset(
}

pub fn build_repo(path: &str) -> Result<Repository, Error> {
Repository::open(path).map_err(|e| e.into())
Repository::discover(path).map_err(|e| e.into())
}

fn find_ref_sha(reference: &Reference) -> Result<String, Error> {
Expand Down
18 changes: 15 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,21 @@ enum AppCommand {
#[structopt(short = "p", long = "port", default_value = "80", value_name = "PORT")]
port: u16,

/// The address for the server to bind on
#[structopt(
short = "b",
long = "address",
default_value = "0.0.0.0",
value_name = "ADDRESS"
)]
address: String,

/// If enabled, configures the server to handle requests as a lambda behind an API Gateway Proxy
/// See: https://github.com/GREsau/rocket-lamb
#[structopt(long = "lambda")]
lambda: bool,

/// Set the size of the SHA LRU cache
#[structopt(long = "cache", default_value = "100", value_name = "CACHE_SIZE")]
cache_size: usize,
//TODO: Add parameter to filter environments to render templates for
Expand Down Expand Up @@ -215,6 +225,7 @@ fn main() -> Result<(), Error> {
AppCommand::Server {
common,
port,
address,
cache_size,
lambda,
} => {
Expand All @@ -227,13 +238,13 @@ fn main() -> Result<(), Error> {
init_cache(&environments, &config_dir)?;
let config_dir = Mutex::new(config_dir);

info!("Starting server on port {}", port);
info!("Starting server on {}:{}", address, port);
let state = ServerState {
environments,
config_dir,
strict: common.strict,
};
start_server(port, lambda, state)?;
start_server(address, port, lambda, state)?;
}
}

Expand All @@ -246,9 +257,10 @@ struct ServerState {
strict: bool,
}

fn start_server(port: u16, lambda: bool, state: ServerState) -> Result<(), Error> {
fn start_server(address: String, port: u16, lambda: bool, state: ServerState) -> Result<(), Error> {
let mut config = Config::development();
config.set_port(port);
config.set_address(address)?;
let server = rocket::custom(config)
.mount(
"/",
Expand Down

0 comments on commit 1832600

Please sign in to comment.