Files
tf-iot-producer/README.md
T

52 lines
1.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# IoT Producer — эмулятор датчиков «Умного дома»
Генерирует случайные IoT-события (температура, влажность, энергопотребление) и отправляет их в очередь RabbitMQ.
## Пайплайн
```
Producer (этот сервис) → RabbitMQ → Consumer → Redis + MongoDB → Dashboard
```
## Датчики
8 виртуальных датчиков, 3 типа:
| Тип | Датчики | Единица | Диапазон |
|---|---|---|---|
| temperature | temp_living, temp_bedroom, temp_office | °C | 1628 |
| humidity | humidity_living, humidity_bed | % | 3070 |
| power_meter | power_kitchen, power_living, power_office | kW | 0.14.0 |
## Переменные окружения
| Переменная | По умолчанию | Описание |
|---|---|---|
| `RABBIT_HOST` | `localhost` | Хост RabbitMQ |
| `RABBIT_PORT` | `5672` | Порт AMQP |
| `RABBIT_USER` | `guest` | Логин |
| `RABBIT_PASS` | `guest` | Пароль |
| `RABBIT_QUEUE` | `iot-events` | Имя очереди |
| `PRODUCE_INTERVAL` | `3` | Интервал между событиями (сек) |
| `PORT` | `3000` | Порт HTTP |
## Эндпоинты
| Путь | Ответ |
|---|---|
| `GET /` | `{"service":"iot-producer","events_sent":N,"errors":N}` |
| `GET /health` | `{"status":"ok"}` |
## Локальный запуск
```bash
npm install
RABBIT_HOST=localhost node server.js
```
## Деплой на Nubes Cloud
1. Запушьте этот репо в свой Gitea
2. В Terraform-конфиге укажите `git_path` на ваш репо и `git_revision` (коммит или `"main"`)
3. Nubes автоматически запустит `npm start`