split the project in 2
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
# tssbot.web
|
||||
|
||||
React + Vite + Tailwind v4 web shell for Toothless' TSS Bot.
|
||||
Toothless' TSS Bot web stack.
|
||||
|
||||
The repo is split into:
|
||||
|
||||
- `frontend/` - React + Vite + Tailwind v4 web shell
|
||||
- `backend/` - backend API service scaffold, ready for database-backed routes
|
||||
- root process files - production frontend server, deploy webhook, PM2 config, and shared repo scripts
|
||||
|
||||
Routes:
|
||||
|
||||
@@ -17,7 +23,7 @@ npm install
|
||||
npm run dev
|
||||
```
|
||||
|
||||
The development server runs on <http://localhost:3001>.
|
||||
The frontend development server runs on <http://localhost:3001>.
|
||||
|
||||
Set `comingsoon=TRUE` in `.env` to serve a temporary coming soon page instead
|
||||
of the app. Omit it, or set any other value, to serve the regular site.
|
||||
@@ -29,11 +35,31 @@ that with `VITE_API_TARGET`:
|
||||
VITE_API_TARGET=http://localhost:8080 npm run dev
|
||||
```
|
||||
|
||||
Run the Rust backend separately:
|
||||
|
||||
```sh
|
||||
npm run dev:backend
|
||||
```
|
||||
|
||||
The backend listens on <http://localhost:6000> by default and reads the SQLite
|
||||
databases configured by `TSS_BATTLES_DB` and `TSS_TEAMS_DB`.
|
||||
|
||||
## Production with PM2
|
||||
|
||||
On a fresh headless Ubuntu server, install the native build tools Rust crates
|
||||
need before the first backend build:
|
||||
|
||||
```sh
|
||||
sudo apt update
|
||||
sudo apt install -y build-essential pkg-config curl
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
||||
. "$HOME/.cargo/env"
|
||||
```
|
||||
|
||||
```sh
|
||||
npm install
|
||||
npm run build
|
||||
npm run build:backend
|
||||
pm2 start ecosystem.config.cjs
|
||||
```
|
||||
|
||||
@@ -191,13 +217,15 @@ The default deploy flow is:
|
||||
```sh
|
||||
git pull --ff-only
|
||||
npm ci --include=dev --include=optional
|
||||
npm run build -- --outDir dist-next
|
||||
npm run build -- --outDir ../dist-next
|
||||
cargo build --manifest-path backend/Cargo.toml --release
|
||||
# the webhook promotes dist-next to dist after carrying over old hashed assets
|
||||
pm2 reload tssbot-web --update-env
|
||||
pm2 reload tssbot-backend --update-env
|
||||
```
|
||||
|
||||
Only processes listed in `PM2_RESTART_TARGETS` are reloaded. The default is
|
||||
`tssbot-web`, so unrelated PM2 processes are left alone. The web server handles
|
||||
`tssbot-web,tssbot-backend`, so unrelated PM2 processes are left alone. The web server handles
|
||||
`SIGINT` and `SIGTERM` by closing its listener and SQLite handles before exit,
|
||||
which lets PM2 finish reloads without dropping active requests. The webhook
|
||||
exits after 24 hours so PM2 restarts it cleanly.
|
||||
|
||||
Reference in New Issue
Block a user