support changing the port from an environment variable (#125)

* support changing the port from an environment variable
* bump dependencies
* bump rust nightly for proc-macro2

Co-authored-by: Qingping Hou <dave2008713@gmail.com>
This commit is contained in:
Charlie Harrington 2022-01-06 19:07:24 -05:00 committed by GitHub
parent e70798bb12
commit df3a76a090
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 300 additions and 170 deletions

View File

@ -8,7 +8,7 @@ on:
env:
# NOTE: this env is also defined in roapi_http_release.yml and columnq_cli_release.yml
RUST_TC_NIGHTLY_VER: "2021-09-25"
RUST_TC_NIGHTLY_VER: "2022-01-05"
jobs:
build:

View File

@ -12,7 +12,7 @@ on:
env:
# NOTE: this env is also defined in build.yml
RUST_TC_NIGHTLY_VER: "2021-09-25"
RUST_TC_NIGHTLY_VER: "2022-01-05"
jobs:
# skip tag version validation on non-release branch run

View File

@ -12,7 +12,7 @@ on:
env:
# NOTE: this env is also defined in build.yml
RUST_TC_NIGHTLY_VER: "2021-09-25"
RUST_TC_NIGHTLY_VER: "2022-01-05"
jobs:
validate-release-tag:

457
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
FROM instrumentisto/rust:nightly-bullseye-2021-09-24 AS builder
FROM instrumentisto/rust:nightly-bullseye-2022-01-03 AS builder
WORKDIR /roapi_src
COPY ./ /roapi_src
RUN apt-get update \

View File

@ -17,9 +17,12 @@ pub struct Application {
impl Application {
pub async fn build(config: Config) -> anyhow::Result<Self> {
let default_host = "127.0.0.1";
let default_port = std::env::var("PORT").unwrap_or_else(|_| "8080".to_string());
let default_addr = default_host.to_string() + ":" + &default_port.to_string();
let addr = (config.addr)
.clone()
.unwrap_or_else(|| "127.0.0.1:8080".to_string());
.unwrap_or_else(|| default_addr.to_string());
let listener = TcpListener::bind(addr)?;
let port = listener.local_addr().unwrap().port();