readme update
This commit is contained in:
@@ -135,6 +135,32 @@ flask --app app create-admin
|
|||||||
Running `create-admin` for an existing username resets its password and grants
|
Running `create-admin` for an existing username resets its password and grants
|
||||||
`is_admin=True`. Log in at `/login`; you land on `/home`.
|
`is_admin=True`. Log in at `/login`; you land on `/home`.
|
||||||
|
|
||||||
|
When the main app runs as a systemd service, run the command as the same user
|
||||||
|
and from the same directory as the service (see `yggdrasil.service`):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd /home/mateusz/prog/yggdrasil/server
|
||||||
|
sudo -u mateusz .venv/bin/flask --app app create-admin
|
||||||
|
```
|
||||||
|
|
||||||
|
To pass credentials without an interactive prompt:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo -u mateusz env ADMIN_USERNAME=admin ADMIN_PASSWORD='secret' \
|
||||||
|
.venv/bin/flask --app app create-admin
|
||||||
|
```
|
||||||
|
|
||||||
|
If the unit sets `USERS_DB_PATH` or `USERS_DATABASE_URL`, add the same variable
|
||||||
|
to the command, for example:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo -u mateusz env USERS_DB_PATH=/data/main_app.db \
|
||||||
|
.venv/bin/flask --app app create-admin
|
||||||
|
```
|
||||||
|
|
||||||
|
The service does not need to be restarted; the new account is used on the next
|
||||||
|
login.
|
||||||
|
|
||||||
## Running
|
## Running
|
||||||
|
|
||||||
The first argument selects the app (`main` or `sensors`), the second the port.
|
The first argument selects the app (`main` or `sensors`), the second the port.
|
||||||
@@ -199,12 +225,49 @@ SENSORS_API_URL=http://localhost:5432 ./run-prod.sh main 8000
|
|||||||
|
|
||||||
### systemd services
|
### systemd services
|
||||||
|
|
||||||
|
Main app only:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo cp yggdrasil.service /etc/systemd/system/
|
||||||
|
sudo systemctl daemon-reload
|
||||||
|
sudo systemctl enable --now yggdrasil
|
||||||
|
```
|
||||||
|
|
||||||
|
Main app and sensors API:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo cp yggdrasil.service yggdrasil-sensors.service /etc/systemd/system/
|
sudo cp yggdrasil.service yggdrasil-sensors.service /etc/systemd/system/
|
||||||
sudo systemctl daemon-reload
|
sudo systemctl daemon-reload
|
||||||
sudo systemctl enable --now yggdrasil yggdrasil-sensors
|
sudo systemctl enable --now yggdrasil yggdrasil-sensors
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Check whether the main service is active:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
systemctl status yggdrasil
|
||||||
|
systemctl is-active yggdrasil # prints: active / inactive / failed
|
||||||
|
systemctl is-enabled yggdrasil # prints: enabled / disabled
|
||||||
|
```
|
||||||
|
|
||||||
|
Quick HTTP check:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -I http://localhost:8000/login
|
||||||
|
ss -ltnp | grep ':8000'
|
||||||
|
```
|
||||||
|
|
||||||
|
Logs:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
journalctl -u yggdrasil -f
|
||||||
|
journalctl -u yggdrasil -n 50 --no-pager
|
||||||
|
journalctl -u yggdrasil-sensors -f # if the sensors service is installed
|
||||||
|
```
|
||||||
|
|
||||||
|
The unit files currently use `User=mateusz` and
|
||||||
|
`WorkingDirectory=/home/mateusz/prog/yggdrasil/server`; adjust them if the
|
||||||
|
deployment path or user is different.
|
||||||
|
|
||||||
| Service | Port | Routes |
|
| Service | Port | Routes |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
| main | 8000 | `/`, `/login`, `/home`, `/sensors`, `/api/docs`, `/api/*` (proxy) |
|
| main | 8000 | `/`, `/login`, `/home`, `/sensors`, `/api/docs`, `/api/*` (proxy) |
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
ssh -R 5432:localhost:8001 vps
|
ssh -R 8001:localhost:8000 vps
|
||||||
|
|||||||
Reference in New Issue
Block a user