diff --git a/.env.example b/.env.example index bb52a2d..cd4da29 100644 --- a/.env.example +++ b/.env.example @@ -1,6 +1,6 @@ # Copy to .env and adjust as needed. HOST=127.0.0.1 -PORT=8080 +PORT=7656 # PostgreSQL connection string. Also read by sqlx's compile-time query macros, # so `cargo check` prepares every query against this database. For local dev: diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 690b9a4..0cdc32b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -298,9 +298,9 @@ jobs: echo "no DATABASE_URL in $env_file" >&2 exit 1 fi - # The unit defaults to 8080; the env file may override. + # The unit defaults to 7656; the env file may override. port=$(sed -n 's/^PORT=\([0-9][0-9]*\)$/\1/p' "$env_file" | tail -n1) - port=${port:-8080} + port=${port:-7656} mkdir -p -- "$deploy_path/data/files" chmod +x -- "$deploy_path/current.new/hezarfen_backend" rm -rf -- "$deploy_path/current.previous" @@ -365,7 +365,7 @@ jobs: env_file=$deploy_path/$3 export XDG_RUNTIME_DIR=/run/user/$(id -u) port=$(sed -n 's/^PORT=\([0-9][0-9]*\)$/\1/p' "$env_file" | tail -n1) - port=${port:-8080} + port=${port:-7656} pid=$(systemctl --user show -p MainPID --value "$service") exe=$(readlink "/proc/$pid/exe") [ "$exe" = "$deploy_path/current/hezarfen_backend" ] || { diff --git a/Containerfile b/Containerfile index 04274c0..8c14e02 100644 --- a/Containerfile +++ b/Containerfile @@ -42,9 +42,9 @@ USER hezarfen # HOST must be 0.0.0.0 so the port mapping can reach the listener. DATABASE_URL # points at the compose Postgres (the control database); /data holds uploads. ENV HOST=0.0.0.0 \ - PORT=8080 \ + PORT=7656 \ DATABASE_URL=postgres://hezarfen:hezarfen@postgres:5432/hezarfen_control -EXPOSE 8080 +EXPOSE 7656 ENTRYPOINT ["/usr/local/bin/hezarfen_backend"] diff --git a/README.md b/README.md index e4c351d..be1d056 100644 --- a/README.md +++ b/README.md @@ -214,7 +214,7 @@ cp .env.example .env # recommended: DATABASE_URL feeds the build too cargo run ``` -Boots on `http://127.0.0.1:8080`, talking to PostgreSQL at `DATABASE_URL` +Boots on `http://127.0.0.1:7656`, talking to PostgreSQL at `DATABASE_URL` (default `postgres://hezarfen:hezarfen@127.0.0.1:5432/hezarfen_control` — the control database) and storing uploaded note files in `./data/files/` (`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 ## Run in a container (podman) ```sh -podman compose up -d --build # build + start, http://127.0.0.1:8080 +podman compose up -d --build # build + start, http://127.0.0.1:7656 podman compose logs -f backend podman compose down # stop (data survives in the volume) ``` @@ -287,7 +287,7 @@ Without compose: ```sh podman build -t hezarfen-backend . -podman run -d --name hezarfen -p 8080:8080 -v hezarfen-data:/data hezarfen-backend +podman run -d --name hezarfen -p 7656:7656 -v hezarfen-data:/data hezarfen-backend ``` ## Multi-school (SaaS) @@ -3647,7 +3647,7 @@ non-empty and contain none of `/ \ ? # %`. ## Quick tour (curl) ```sh -BASE=http://127.0.0.1:8080 +BASE=http://127.0.0.1:7656 JAR=/tmp/hz.cookies # SCHOOL is the slug a builder gave this school (see "Multi-school (SaaS)"). diff --git a/compose.yaml b/compose.yaml index 5623f58..604572b 100644 --- a/compose.yaml +++ b/compose.yaml @@ -28,12 +28,12 @@ services: image: localhost/hezarfen-backend:latest container_name: hezarfen-backend ports: - - "8080:8080" + - "7656:7656" # AI bridge (QUIC = UDP). Paired with AI_QUIC_ADDR below. - "8090:8090/udp" environment: HOST: 0.0.0.0 - PORT: "8080" + PORT: "7656" # The control database: the school registry + the builder accounts. Each # school lives in a Postgres database of its own, named from its slug. DATABASE_URL: postgres://hezarfen:hezarfen@postgres:5432/hezarfen_control @@ -78,7 +78,7 @@ services: condition: service_healthy restart: unless-stopped healthcheck: - test: ["CMD", "curl", "-fsS", "http://127.0.0.1:8080/"] + test: ["CMD", "curl", "-fsS", "http://127.0.0.1:7656/"] interval: 30s timeout: 5s retries: 3 diff --git a/deploy/hezarfen.service b/deploy/hezarfen.service index 0f238e8..2ea10b8 100644 --- a/deploy/hezarfen.service +++ b/deploy/hezarfen.service @@ -18,7 +18,7 @@ # TRUST_PROXY=true client IPs from X-Forwarded-For behind a proxy # # The service binds loopback only by default — terminate TLS on a reverse -# proxy and forward to 127.0.0.1:8080. +# proxy and forward to 127.0.0.1:7656. [Unit] Description=Hezarfen backend (school management API) @@ -30,7 +30,7 @@ Type=simple ExecStart=%h/hezarfen/current/hezarfen_backend WorkingDirectory=%h/hezarfen/current Environment=HOST=127.0.0.1 -Environment=PORT=8080 +Environment=PORT=7656 Environment=FILES_PATH=%h/hezarfen/data/files Environment=RUST_LOG=info,hezarfen_backend=debug EnvironmentFile=%h/hezarfen/hezarfen.env diff --git a/src/config.rs b/src/config.rs index b2742a1..462f9a9 100644 --- a/src/config.rs +++ b/src/config.rs @@ -149,9 +149,9 @@ fn parse_timeout(value: Option, default: u64) -> u64 { asked } -/// Parse the `PORT` value, falling back to 8080 when unset or unparseable. +/// Parse the `PORT` value, falling back to 7656 when unset or unparseable. fn parse_port(value: Option) -> u16 { - value.and_then(|p| p.parse().ok()).unwrap_or(8080) + value.and_then(|p| p.parse().ok()).unwrap_or(7656) } /// Parse a boolean toggle: `1` / `true` / `yes` / `on` (any case, trimmed) are @@ -223,7 +223,7 @@ mod tests { #[tokio::test] async fn defaults_when_absent() { - assert_eq!(parse_port(None), 8080); + assert_eq!(parse_port(None), 7656); } #[tokio::test] @@ -244,7 +244,7 @@ mod tests { #[tokio::test] async fn falls_back_on_garbage() { - assert_eq!(parse_port(Some("not-a-port".into())), 8080); - assert_eq!(parse_port(Some(String::new())), 8080); + assert_eq!(parse_port(Some("not-a-port".into())), 7656); + assert_eq!(parse_port(Some(String::new())), 7656); } }