diff --git a/README.md b/README.md index 08d1270..c733a7e 100644 --- a/README.md +++ b/README.md @@ -238,6 +238,7 @@ You can also use [docker image](https://hub.docker.com/r/jqtype/rpxy) instead of - `HOST_GID` (default: `900`): `GID` of `HOST_USER` - `LOG_LEVEL=debug|info|warn|error`: Log level - `LOG_TO_FILE=true|false`: Enable logging to the log file `/rpxy/log/rpxy.log` using `logrotate`. You should mount `/rpxy/log` via docker volume option if enabled. The log dir and file will be owned by the `HOST_USER` with `HOST_UID:HOST_GID` on the host machine. Hence, `HOST_USER`, `HOST_UID` and `HOST_GID` should be the same as ones of the user who executes the `rpxy` docker container on the host. +- `WATCH=true|false` (default: `false`): Activate continuous watching of the config file if true. Other than them, all you need is to mount your `config.toml` as `/etc/rpxy.toml` and certificates/private keys as you like through the docker volume option. See [`docker/docker-compose.yml`](./docker/docker-compose.yml) for the detailed configuration. Note that the file path of keys and certificates must be ones in your docker container. diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index d817918..886a471 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -11,12 +11,16 @@ services: build: context: ../ dockerfile: ./docker/Dockerfile + platforms: # Choose your platforms + - "linux/amd64" + # - "linux/arm64" environment: - LOG_LEVEL=debug - LOG_TO_FILE=true - HOST_USER=jun - HOST_UID=501 - HOST_GID=501 + # - WATCH=true tty: false privileged: true volumes: diff --git a/docker/run.sh b/docker/run.sh index 6f83ff8..25f50d6 100644 --- a/docker/run.sh +++ b/docker/run.sh @@ -7,4 +7,19 @@ if [ -z $LOG_LEVEL ]; then fi echo "rpxy: Logging with level ${LOG_LEVEL}" -RUST_LOG=${LOG_LEVEL} /rpxy/bin/rpxy --config ${CONFIG_FILE} +# continuously watch and reload the config file +if [ -z $WATCH ]; then + WATCH=false +else + if [ "$WATCH" = "true" ]; then + WATCH=true + else + WATCH=false + fi +fi + +if $WATCH ; then + RUST_LOG=${LOG_LEVEL} /rpxy/bin/rpxy --config ${CONFIG_FILE} -w +else + RUST_LOG=${LOG_LEVEL} /rpxy/bin/rpxy --config ${CONFIG_FILE} +fi diff --git a/rpxy-bin/Cargo.toml b/rpxy-bin/Cargo.toml index 0ed54d2..870dc0f 100644 --- a/rpxy-bin/Cargo.toml +++ b/rpxy-bin/Cargo.toml @@ -21,6 +21,7 @@ rpxy-lib = { path = "../rpxy-lib/", features = ["http3", "sticky-cookie"] } anyhow = "1.0.72" rustc-hash = "1.1.0" serde = { version = "1.0.177", default-features = false, features = ["derive"] } +develop derive_builder = "0.12.0" tokio = { version = "1.29.1", default-features = false, features = [ "net",