Default HTTP bind port 7656
Browse files at this commit81ac0fb5db6f50bd746ca45c1357aaa7655a2950Parent: c782987- chore
- default HTTP bind port 7656
7 changed files +20 -20
- .env.example +1 -1
- .github/workflows/main.yml +3 -3
- Containerfile +2 -2
- README.md +4 -4
- compose.yaml +3 -3
- deploy/hezarfen.service +2 -2
- src/config.rs +5 -5
.env.examplemodified+1 -1
| @@ -1,6 +1,6 @@ | |||
| 1 | # Copy to .env and adjust as needed. | 1 | # Copy to .env and adjust as needed. |
| 2 | HOST=127.0.0.1 | 2 | HOST=127.0.0.1 |
| 3 | -PORT=8080 | 3 | +PORT=7656 |
| 4 | 4 | ||
| 5 | # PostgreSQL connection string. Also read by sqlx's compile-time query macros, | 5 | # PostgreSQL connection string. Also read by sqlx's compile-time query macros, |
| 6 | # so `cargo check` prepares every query against this database. For local dev: | 6 | # so `cargo check` prepares every query against this database. For local dev: |
.github/workflows/main.ymlmodified+3 -3
| @@ -298,9 +298,9 @@ jobs: | |||
| 298 | echo "no DATABASE_URL in $env_file" >&2 | 298 | echo "no DATABASE_URL in $env_file" >&2 |
| 299 | exit 1 | 299 | exit 1 |
| 300 | fi | 300 | fi |
| 301 | - # The unit defaults to 8080; the env file may override. | 301 | + # The unit defaults to 7656; the env file may override. |
| 302 | port=$(sed -n 's/^PORT=\([0-9][0-9]*\)$/\1/p' "$env_file" | tail -n1) | 302 | port=$(sed -n 's/^PORT=\([0-9][0-9]*\)$/\1/p' "$env_file" | tail -n1) |
| 303 | - port=${port:-8080} | 303 | + port=${port:-7656} |
| 304 | mkdir -p -- "$deploy_path/data/files" | 304 | mkdir -p -- "$deploy_path/data/files" |
| 305 | chmod +x -- "$deploy_path/current.new/hezarfen_backend" | 305 | chmod +x -- "$deploy_path/current.new/hezarfen_backend" |
| 306 | rm -rf -- "$deploy_path/current.previous" | 306 | rm -rf -- "$deploy_path/current.previous" |
| @@ -365,7 +365,7 @@ jobs: | |||
| 365 | env_file=$deploy_path/$3 | 365 | env_file=$deploy_path/$3 |
| 366 | export XDG_RUNTIME_DIR=/run/user/$(id -u) | 366 | export XDG_RUNTIME_DIR=/run/user/$(id -u) |
| 367 | port=$(sed -n 's/^PORT=\([0-9][0-9]*\)$/\1/p' "$env_file" | tail -n1) | 367 | port=$(sed -n 's/^PORT=\([0-9][0-9]*\)$/\1/p' "$env_file" | tail -n1) |
| 368 | - port=${port:-8080} | 368 | + port=${port:-7656} |
| 369 | pid=$(systemctl --user show -p MainPID --value "$service") | 369 | pid=$(systemctl --user show -p MainPID --value "$service") |
| 370 | exe=$(readlink "/proc/$pid/exe") | 370 | exe=$(readlink "/proc/$pid/exe") |
| 371 | [ "$exe" = "$deploy_path/current/hezarfen_backend" ] || { | 371 | [ "$exe" = "$deploy_path/current/hezarfen_backend" ] || { |
Containerfilemodified+2 -2
| @@ -42,9 +42,9 @@ USER hezarfen | |||
| 42 | # HOST must be 0.0.0.0 so the port mapping can reach the listener. DATABASE_URL | 42 | # HOST must be 0.0.0.0 so the port mapping can reach the listener. DATABASE_URL |
| 43 | # points at the compose Postgres (the control database); /data holds uploads. | 43 | # points at the compose Postgres (the control database); /data holds uploads. |
| 44 | ENV HOST=0.0.0.0 \ | 44 | ENV HOST=0.0.0.0 \ |
| 45 | - PORT=8080 \ | 45 | + PORT=7656 \ |
| 46 | DATABASE_URL=postgres://hezarfen:hezarfen@postgres:5432/hezarfen_control | 46 | DATABASE_URL=postgres://hezarfen:hezarfen@postgres:5432/hezarfen_control |
| 47 | 47 | ||
| 48 | -EXPOSE 8080 | 48 | +EXPOSE 7656 |
| 49 | 49 | ||
| 50 | ENTRYPOINT ["/usr/local/bin/hezarfen_backend"] | 50 | ENTRYPOINT ["/usr/local/bin/hezarfen_backend"] |
README.mdmodified+4 -4
| @@ -214,7 +214,7 @@ cp .env.example .env # recommended: DATABASE_URL feeds the build too | |||
| 214 | cargo run | 214 | cargo run |
| 215 | ``` | 215 | ``` |
| 216 | 216 | ||
| 217 | -Boots on `http://127.0.0.1:8080`, talking to PostgreSQL at `DATABASE_URL` | 217 | +Boots on `http://127.0.0.1:7656`, talking to PostgreSQL at `DATABASE_URL` |
| 218 | (default `postgres://hezarfen:hezarfen@127.0.0.1:5432/hezarfen_control` — | 218 | (default `postgres://hezarfen:hezarfen@127.0.0.1:5432/hezarfen_control` — |
| 219 | the control database) and storing uploaded note files in `./data/files/` | 219 | the control database) and storing uploaded note files in `./data/files/` |
| 220 | (`FILES_PATH`, created at startup). `DATABASE_URL` is also read by sqlx's | 220 | (`FILES_PATH`, created at startup). `DATABASE_URL` is also read by sqlx's |
| @@ -230,7 +230,7 @@ the same way at mint. Interactive API docs (Swagger UI) are served at | |||
| 230 | ## Run in a container (podman) | 230 | ## Run in a container (podman) |
| 231 | 231 | ||
| 232 | ```sh | 232 | ```sh |
| 233 | -podman compose up -d --build # build + start, http://127.0.0.1:8080 | 233 | +podman compose up -d --build # build + start, http://127.0.0.1:7656 |
| 234 | podman compose logs -f backend | 234 | podman compose logs -f backend |
| 235 | podman compose down # stop (data survives in the volume) | 235 | podman compose down # stop (data survives in the volume) |
| 236 | ``` | 236 | ``` |
| @@ -287,7 +287,7 @@ Without compose: | |||
| 287 | 287 | ||
| 288 | ```sh | 288 | ```sh |
| 289 | podman build -t hezarfen-backend . | 289 | podman build -t hezarfen-backend . |
| 290 | -podman run -d --name hezarfen -p 8080:8080 -v hezarfen-data:/data hezarfen-backend | 290 | +podman run -d --name hezarfen -p 7656:7656 -v hezarfen-data:/data hezarfen-backend |
| 291 | ``` | 291 | ``` |
| 292 | 292 | ||
| 293 | ## Multi-school (SaaS) | 293 | ## Multi-school (SaaS) |
| @@ -3647,7 +3647,7 @@ non-empty and contain none of `/ \ ? # %`. | |||
| 3647 | ## Quick tour (curl) | 3647 | ## Quick tour (curl) |
| 3648 | 3648 | ||
| 3649 | ```sh | 3649 | ```sh |
| 3650 | -BASE=http://127.0.0.1:8080 | 3650 | +BASE=http://127.0.0.1:7656 |
| 3651 | JAR=/tmp/hz.cookies | 3651 | JAR=/tmp/hz.cookies |
| 3652 | 3652 | ||
| 3653 | # SCHOOL is the slug a builder gave this school (see "Multi-school (SaaS)"). | 3653 | # SCHOOL is the slug a builder gave this school (see "Multi-school (SaaS)"). |
compose.yamlmodified+3 -3
| @@ -28,12 +28,12 @@ services: | |||
| 28 | image: localhost/hezarfen-backend:latest | 28 | image: localhost/hezarfen-backend:latest |
| 29 | container_name: hezarfen-backend | 29 | container_name: hezarfen-backend |
| 30 | ports: | 30 | ports: |
| 31 | - - "8080:8080" | 31 | + - "7656:7656" |
| 32 | # AI bridge (QUIC = UDP). Paired with AI_QUIC_ADDR below. | 32 | # AI bridge (QUIC = UDP). Paired with AI_QUIC_ADDR below. |
| 33 | - "8090:8090/udp" | 33 | - "8090:8090/udp" |
| 34 | environment: | 34 | environment: |
| 35 | HOST: 0.0.0.0 | 35 | HOST: 0.0.0.0 |
| 36 | - PORT: "8080" | 36 | + PORT: "7656" |
| 37 | # The control database: the school registry + the builder accounts. Each | 37 | # The control database: the school registry + the builder accounts. Each |
| 38 | # school lives in a Postgres database of its own, named from its slug. | 38 | # school lives in a Postgres database of its own, named from its slug. |
| 39 | DATABASE_URL: postgres://hezarfen:hezarfen@postgres:5432/hezarfen_control | 39 | DATABASE_URL: postgres://hezarfen:hezarfen@postgres:5432/hezarfen_control |
| @@ -78,7 +78,7 @@ services: | |||
| 78 | condition: service_healthy | 78 | condition: service_healthy |
| 79 | restart: unless-stopped | 79 | restart: unless-stopped |
| 80 | healthcheck: | 80 | healthcheck: |
| 81 | - test: ["CMD", "curl", "-fsS", "http://127.0.0.1:8080/"] | 81 | + test: ["CMD", "curl", "-fsS", "http://127.0.0.1:7656/"] |
| 82 | interval: 30s | 82 | interval: 30s |
| 83 | timeout: 5s | 83 | timeout: 5s |
| 84 | retries: 3 | 84 | retries: 3 |
deploy/hezarfen.servicemodified+2 -2
| @@ -18,7 +18,7 @@ | |||
| 18 | # TRUST_PROXY=true client IPs from X-Forwarded-For behind a proxy | 18 | # TRUST_PROXY=true client IPs from X-Forwarded-For behind a proxy |
| 19 | # | 19 | # |
| 20 | # The service binds loopback only by default — terminate TLS on a reverse | 20 | # The service binds loopback only by default — terminate TLS on a reverse |
| 21 | -# proxy and forward to 127.0.0.1:8080. | 21 | +# proxy and forward to 127.0.0.1:7656. |
| 22 | 22 | ||
| 23 | [Unit] | 23 | [Unit] |
| 24 | Description=Hezarfen backend (school management API) | 24 | Description=Hezarfen backend (school management API) |
| @@ -30,7 +30,7 @@ Type=simple | |||
| 30 | ExecStart=%h/hezarfen/current/hezarfen_backend | 30 | ExecStart=%h/hezarfen/current/hezarfen_backend |
| 31 | WorkingDirectory=%h/hezarfen/current | 31 | WorkingDirectory=%h/hezarfen/current |
| 32 | Environment=HOST=127.0.0.1 | 32 | Environment=HOST=127.0.0.1 |
| 33 | -Environment=PORT=8080 | 33 | +Environment=PORT=7656 |
| 34 | Environment=FILES_PATH=%h/hezarfen/data/files | 34 | Environment=FILES_PATH=%h/hezarfen/data/files |
| 35 | Environment=RUST_LOG=info,hezarfen_backend=debug | 35 | Environment=RUST_LOG=info,hezarfen_backend=debug |
| 36 | EnvironmentFile=%h/hezarfen/hezarfen.env | 36 | EnvironmentFile=%h/hezarfen/hezarfen.env |
src/config.rsmodified+5 -5
| @@ -149,9 +149,9 @@ fn parse_timeout(value: Option<String>, default: u64) -> u64 { | |||
| 149 | asked | 149 | asked |
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | -/// Parse the `PORT` value, falling back to 8080 when unset or unparseable. | 152 | +/// Parse the `PORT` value, falling back to 7656 when unset or unparseable. |
| 153 | fn parse_port(value: Option<String>) -> u16 { | 153 | fn parse_port(value: Option<String>) -> u16 { |
| 154 | - value.and_then(|p| p.parse().ok()).unwrap_or(8080) | 154 | + value.and_then(|p| p.parse().ok()).unwrap_or(7656) |
| 155 | } | 155 | } |
| 156 | 156 | ||
| 157 | /// Parse a boolean toggle: `1` / `true` / `yes` / `on` (any case, trimmed) are | 157 | /// Parse a boolean toggle: `1` / `true` / `yes` / `on` (any case, trimmed) are |
| @@ -223,7 +223,7 @@ mod tests { | |||
| 223 | 223 | ||
| 224 | #[tokio::test] | 224 | #[tokio::test] |
| 225 | async fn defaults_when_absent() { | 225 | async fn defaults_when_absent() { |
| 226 | - assert_eq!(parse_port(None), 8080); | 226 | + assert_eq!(parse_port(None), 7656); |
| 227 | } | 227 | } |
| 228 | 228 | ||
| 229 | #[tokio::test] | 229 | #[tokio::test] |
| @@ -244,7 +244,7 @@ mod tests { | |||
| 244 | 244 | ||
| 245 | #[tokio::test] | 245 | #[tokio::test] |
| 246 | async fn falls_back_on_garbage() { | 246 | async fn falls_back_on_garbage() { |
| 247 | - assert_eq!(parse_port(Some("not-a-port".into())), 8080); | 247 | + assert_eq!(parse_port(Some("not-a-port".into())), 7656); |
| 248 | - assert_eq!(parse_port(Some(String::new())), 8080); | 248 | + assert_eq!(parse_port(Some(String::new())), 7656); |
| 249 | } | 249 | } |
| 250 | } | 250 | } |