State-Machine Orchestrator для запуска Telegram-ботов в Docker
git clone https://github.com/TimaxLacs/tg-runner-orchestrator.git
cd tg-runner-orchestrator
# Запускаем Redis + Orchestrator
docker-compose up -d
# Проверяем
curl http://localhost:8000/_public/status
# {"status": "ok"}Затем на другом сервере запустите воркер:
git clone https://github.com/TimaxLacs/tg-runner-worker.git
cd tg-runner-worker
pip install -e .
export ORCHESTRATOR_URL=http://ORCHESTRATOR_SERVER_IP:8000
export WORKER_TOKEN=test-worker-token
python -m bot_runner_workergit clone https://github.com/TimaxLacs/tg-runner-orchestrator.git
cd tg-runner-orchestrator
# Клонируем воркер в поддиректорию
git clone https://github.com/TimaxLacs/tg-runner-worker.git bot_runner_worker
# Запускаем полный стек
docker-compose -f docker-compose.full.yml up -d
# Проверяем
curl http://localhost:8000/_public/status┌─────────────────┐ ┌─────────────────────┐ ┌──────────────────┐
│ tg-runner │────▶│ tg-runner- │────▶│ tg-runner- │
│ (CLI) │ │ orchestrator │ │ worker │
│ │ │ (этот репо) │ │ (другой сервер) │
└─────────────────┘ └─────────────────────┘ └──────────────────┘
│ │ │
│ │ ▼
│ ┌────┴────┐ ┌──────────────┐
│ │ Redis │ │ Docker │
│ └─────────┘ │ Containers │
│ └──────────────┘
│
pip install tg-runner-cli
| Переменная | Описание | По умолчанию |
|---|---|---|
REDIS_HOST |
Хост Redis | localhost |
REDIS_PORT |
Порт Redis | 6379 |
CLIENT_TOKEN |
Токен для CLI/клиентов | test-client-token |
GLOBAL_WORKER_TOKEN |
Токен для воркеров | test-worker-token |
API_PORT |
Порт API | 8000 |
LOG_LEVEL |
Уровень логов | INFO |
# Создайте .env файл
cat > .env << EOF
CLIENT_TOKEN=my-secret-client-token
WORKER_TOKEN=my-secret-worker-token
EOF
# Запустите с этими токенами
docker-compose up -d| Файл | Описание |
|---|---|
docker-compose.yml |
Redis + Orchestrator (воркер отдельно) |
docker-compose.full.yml |
Полный стек включая воркер |
| Компонент | Описание | Установка |
|---|---|---|
| tg-runner-orchestrator | Этот репозиторий | docker-compose up |
| tg-runner-worker | Worker для Docker | pip install -e . |
| tg-runner-cli | CLI | pip install tg-runner-cli |
| tg-runner-worker-sdk | SDK для воркеров | pip install tg-runner-worker-sdk |
После запуска orchestrator + worker:
# Установите CLI
pip install tg-runner-cli
# Настройте
export TG_RUNNER_URL=http://localhost:8000
export TG_RUNNER_TOKEN=test-client-token
# Запустите бота
tg-runner start my-bot --simple bot.py -r "aiogram>=3.0" -e "BOT_TOKEN=123:ABC"
# Проверьте
tg-runner list
tg-runner logs my-bot
tg-runner stop my-botMIT License
Made with ❤️ by TimaxLacs