docs
This commit is contained in:
@@ -12,11 +12,46 @@ The abstraction layer is an asyncio-based worker that manages device communicati
|
||||
|
||||
## Running
|
||||
|
||||
### Local Development
|
||||
|
||||
```bash
|
||||
# Start the abstraction worker
|
||||
poetry run python -m apps.abstraction.main
|
||||
```
|
||||
|
||||
### Docker Container
|
||||
|
||||
#### Build Image
|
||||
|
||||
```bash
|
||||
docker build -t abstraction:dev -f apps/abstraction/Dockerfile .
|
||||
```
|
||||
|
||||
#### Run Container
|
||||
|
||||
```bash
|
||||
docker run --rm \
|
||||
-v $(pwd)/config:/app/config:ro \
|
||||
-e MQTT_BROKER=172.16.2.16 \
|
||||
-e MQTT_PORT=1883 \
|
||||
-e REDIS_HOST=172.23.1.116 \
|
||||
-e REDIS_PORT=6379 \
|
||||
-e REDIS_DB=8 \
|
||||
abstraction:dev
|
||||
```
|
||||
|
||||
#### Environment Variables
|
||||
|
||||
| Variable | Default | Description |
|
||||
|----------|---------|-------------|
|
||||
| `MQTT_BROKER` | `172.16.2.16` | MQTT broker hostname/IP |
|
||||
| `MQTT_PORT` | `1883` | MQTT broker port |
|
||||
| `REDIS_HOST` | `localhost` | Redis server hostname/IP |
|
||||
| `REDIS_PORT` | `6379` | Redis server port |
|
||||
| `REDIS_DB` | `0` | Redis database number |
|
||||
|
||||
### What the Worker Does
|
||||
|
||||
The worker will:
|
||||
1. Load configuration from `config/devices.yaml`
|
||||
2. Connect to MQTT broker (172.16.2.16:1883)
|
||||
|
||||
@@ -22,7 +22,6 @@ WORKDIR /app
|
||||
|
||||
# Install system dependencies
|
||||
RUN apk add --no-cache \
|
||||
curl \
|
||||
gcc \
|
||||
musl-dev \
|
||||
linux-headers
|
||||
@@ -42,10 +41,6 @@ RUN chown -R app:app /app
|
||||
# Switch to non-root user
|
||||
USER app
|
||||
|
||||
# Health check
|
||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
||||
CMD curl -f http://localhost:8001/health || exit 1
|
||||
|
||||
# Expose port
|
||||
EXPOSE 8001
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ poetry run uvicorn apps.api.main:app --reload
|
||||
### Production Mode
|
||||
|
||||
```bash
|
||||
poetry run uvicorn apps.api.main:app --host 0.0.0.0 --port 8000
|
||||
poetry run uvicorn apps.api.main:app --host 0.0.0.0 --port 8001
|
||||
```
|
||||
|
||||
### Using Python directly
|
||||
@@ -29,6 +29,39 @@ poetry run uvicorn apps.api.main:app --host 0.0.0.0 --port 8000
|
||||
poetry run python -m apps.api.main
|
||||
```
|
||||
|
||||
### Docker Container
|
||||
|
||||
#### Build Image
|
||||
|
||||
```bash
|
||||
docker build -t api:dev -f apps/api/Dockerfile .
|
||||
```
|
||||
|
||||
#### Run Container
|
||||
|
||||
```bash
|
||||
docker run --rm -p 8001:8001 \
|
||||
-v $(pwd)/config:/app/config:ro \
|
||||
-e MQTT_BROKER=172.16.2.16 \
|
||||
-e MQTT_PORT=1883 \
|
||||
-e REDIS_HOST=172.23.1.116 \
|
||||
-e REDIS_PORT=6379 \
|
||||
-e REDIS_DB=8 \
|
||||
-e REDIS_CHANNEL=ui:updates \
|
||||
api:dev
|
||||
```
|
||||
|
||||
#### Environment Variables
|
||||
|
||||
| Variable | Default | Description |
|
||||
|----------|---------|-------------|
|
||||
| `MQTT_BROKER` | `172.16.2.16` | MQTT broker hostname/IP |
|
||||
| `MQTT_PORT` | `1883` | MQTT broker port |
|
||||
| `REDIS_HOST` | `localhost` | Redis server hostname/IP |
|
||||
| `REDIS_PORT` | `6379` | Redis server port |
|
||||
| `REDIS_DB` | `0` | Redis database number |
|
||||
| `REDIS_CHANNEL` | `ui:updates` | Redis pub/sub channel |
|
||||
|
||||
## API Endpoints
|
||||
|
||||
### `GET /health`
|
||||
|
||||
@@ -19,7 +19,6 @@ WORKDIR /app
|
||||
|
||||
# Install system dependencies
|
||||
RUN apk add --no-cache \
|
||||
curl \
|
||||
gcc \
|
||||
musl-dev \
|
||||
linux-headers
|
||||
@@ -38,10 +37,6 @@ RUN chown -R app:app /app
|
||||
# Switch to non-root user
|
||||
USER app
|
||||
|
||||
# Health check
|
||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
||||
CMD curl -f http://localhost:8010/health || exit 1
|
||||
|
||||
# Expose port
|
||||
EXPOSE 8010
|
||||
|
||||
|
||||
@@ -28,22 +28,50 @@ Der Simulator ist bereits Teil des Projekts. Keine zusätzlichen Dependencies er
|
||||
|
||||
## Start
|
||||
|
||||
### Local Development
|
||||
|
||||
```bash
|
||||
# Standard-Start (Port 8003)
|
||||
poetry run uvicorn apps.simulator.main:app --host 0.0.0.0 --port 8003
|
||||
# Standard-Start (Port 8010)
|
||||
poetry run uvicorn apps.simulator.main:app --host 0.0.0.0 --port 8010
|
||||
|
||||
# Mit Auto-Reload für Entwicklung
|
||||
poetry run uvicorn apps.simulator.main:app --host 0.0.0.0 --port 8003 --reload
|
||||
poetry run uvicorn apps.simulator.main:app --host 0.0.0.0 --port 8010 --reload
|
||||
|
||||
# Im Hintergrund
|
||||
poetry run uvicorn apps.simulator.main:app --host 0.0.0.0 --port 8003 > /tmp/simulator.log 2>&1 &
|
||||
poetry run uvicorn apps.simulator.main:app --host 0.0.0.0 --port 8010 > /tmp/simulator.log 2>&1 &
|
||||
```
|
||||
|
||||
### Docker Container
|
||||
|
||||
#### Build Image
|
||||
|
||||
```bash
|
||||
docker build -t simulator:dev -f apps/simulator/Dockerfile .
|
||||
```
|
||||
|
||||
#### Run Container
|
||||
|
||||
```bash
|
||||
docker run --rm -p 8010:8010 \
|
||||
-e MQTT_BROKER=172.16.2.16 \
|
||||
-e MQTT_PORT=1883 \
|
||||
-e SIM_PORT=8010 \
|
||||
simulator:dev
|
||||
```
|
||||
|
||||
#### Environment Variables
|
||||
|
||||
| Variable | Default | Description |
|
||||
|----------|---------|-------------|
|
||||
| `MQTT_BROKER` | `172.16.2.16` | MQTT broker hostname/IP |
|
||||
| `MQTT_PORT` | `1883` | MQTT broker port |
|
||||
| `SIM_PORT` | `8010` | Port for web interface |
|
||||
|
||||
## Web-Interface
|
||||
|
||||
Öffne im Browser:
|
||||
```
|
||||
http://localhost:8003
|
||||
http://localhost:8010
|
||||
```
|
||||
|
||||
### Features im Dashboard
|
||||
|
||||
@@ -27,6 +27,32 @@ poetry run uvicorn apps.ui.main:app --reload --port 8002
|
||||
poetry run python -m apps.ui.main
|
||||
```
|
||||
|
||||
### Docker Container
|
||||
|
||||
#### Build Image
|
||||
|
||||
```bash
|
||||
docker build -t ui:dev -f apps/ui/Dockerfile .
|
||||
```
|
||||
|
||||
#### Run Container
|
||||
|
||||
```bash
|
||||
docker run --rm -p 8002:8002 \
|
||||
-e UI_PORT=8002 \
|
||||
-e API_BASE=http://localhost:8001 \
|
||||
-e BASE_PATH=/ \
|
||||
ui:dev
|
||||
```
|
||||
|
||||
#### Environment Variables
|
||||
|
||||
| Variable | Default | Description |
|
||||
|----------|---------|-------------|
|
||||
| `UI_PORT` | `8002` | Port for UI server |
|
||||
| `API_BASE` | `http://localhost:8001` | Base URL for API service |
|
||||
| `BASE_PATH` | `/` | Base path for routing |
|
||||
|
||||
## Project Structure
|
||||
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user