feat(axum): add env file

This commit is contained in:
xfy
2024-09-14 15:40:33 +08:00
parent 8e9baad5c2
commit 2a74778417
7 changed files with 82 additions and 3 deletions

View File

@ -0,0 +1,15 @@
root = true
[*]
indent_style = space
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
indent_size = 4
charset = utf-8
[*.{yml,yaml}]
indent_size = 2
[Makefile]
indent_style = tab

View File

@ -0,0 +1 @@
PHTHONUS_PORT=4000

View File

@ -1 +1,2 @@
target/ target/
.env

View File

@ -567,7 +567,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
[[package]] [[package]]
name = "phthonus-axum" name = "phthonus"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",

View File

@ -1,5 +1,5 @@
[package] [package]
name = "phthonus-axum" name = "phthonus"
version = "0.1.0" version = "0.1.0"
edition = "2021" edition = "2021"

62
web/Rust/axum/Makefile Normal file
View File

@ -0,0 +1,62 @@
CARGO = cargo
RUSTC = rustc
CROSS = cross
all: build
build:
$(CARGO) build
release: clean
$(CARGO) build --release
dev:
PHTHONUS_LOG=debug $(CARGO) watch -x run
run:
$(CARGO) run
test:
$(CARGO) test
clean:
$(CARGO) clean
clean-release:
rm -rf ./target/release/
rm -rf ./target/debug/
check:
$(CARGO) check
format:
$(CARGO) fmt
lint:
$(CARGO) clippy
fix:
$(CARGO) fix --allow-dirty --all-features && $(CARGO) fmt
build-linux-musl: clean-release
$(CROSS) build --release --target x86_64-unknown-linux-musl
build-linux-gnu: clean-release
$(CROSS) build --release --target x86_64-unknown-linux-gnu
build-windows-gnu: clean-release
$(CROSS) build --release --target x86_64-pc-windows-gnu
build-freebsd: clean-release
$(CROSS) build --release --target x86_64-unknown-freebsd
build-loongarch: clean-release
$(CROSS) build --release --target loongarch64-unknown-linux-gnu
deps:
python -m venv venus \
&& source venus/bin/activate \
&& pip install -r scripts/requirements.txt \
&& python scripts/download-core.py
.PHONY: all

View File

@ -22,7 +22,7 @@ async fn main() -> Result<()> {
init_logger(); init_logger();
info!("Hello, world!"); info!("Hello, world!");
let port = env::var("VENUS_PORT") let port = env::var("PHTHONUS_PORT")
.map(|port| port.parse::<u16>().unwrap_or(DEFAULT_PORT)) .map(|port| port.parse::<u16>().unwrap_or(DEFAULT_PORT))
.unwrap_or(DEFAULT_PORT); .unwrap_or(DEFAULT_PORT);
let addr = SocketAddr::from(([0, 0, 0, 0], port)); let addr = SocketAddr::from(([0, 0, 0, 0], port));