mirror of
https://github.com/roapi/roapi.git
synced 2026-06-05 21:04:02 +08:00
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:
parent
e70798bb12
commit
df3a76a090
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@ -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:
|
||||
|
||||
2
.github/workflows/columnq_cli_release.yml
vendored
2
.github/workflows/columnq_cli_release.yml
vendored
@ -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
|
||||
|
||||
2
.github/workflows/roapi_http_release.yml
vendored
2
.github/workflows/roapi_http_release.yml
vendored
@ -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
457
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -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 \
|
||||
|
||||
@ -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();
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user