Update user link handling in main.go to ensure consistent fallback messages and improve error handling for missing links.
Publish telemt-bot Docker image / build-and-push (push) Successful in 25s

This commit is contained in:
Denozordec
2026-03-09 19:09:31 +07:00
parent d8ddc53640
commit f7e8e58262
2 changed files with 196 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
cd /opt/telemt-plus
# 0) Остановить telemt перед переносом
docker compose stop telemt
# 1) Создать новую структуру
mkdir -p telemt-data/cache
# 2) Резервная копия текущих файлов
mkdir -p backup-telemt-$(date +%F-%H%M%S)
cp -a config.toml proxy-secret cache docker-compose.yml backup-telemt-$(date +%F-%H%M%S)/ 2>/dev/null || true
# 3) Перенос данных в telemt-data
[ -f config.toml ] && cp -f config.toml telemt-data/config.toml
[ -f proxy-secret ] && cp -f proxy-secret telemt-data/proxy-secret
[ -d cache ] && cp -a cache/. telemt-data/cache/
# 4) Права под пользователя контейнера telemt (uid/gid 999)
chown -R 999:999 telemt-data
find telemt-data -type d -exec chmod 750 {} \;
find telemt-data -type f -exec chmod 640 {} \;
chmod 660 telemt-data/config.toml 2>/dev/null || true
chmod 770 telemt-data/cache 2>/dev/null || true
# 5) Перезапуск контейнера после правки compose
docker compose up -d --force-recreate telemt
# 6) Проверка
docker logs --tail=100 telemt
docker exec telemt sh -lc 'ls -ld /run/telemt /run/telemt/cache; ls -l /run/telemt/config.toml'
+166
View File
@@ -0,0 +1,166 @@
# Синхронизация `config.toml` между `mtg.ivx.su` и `gt1.ivx.su`
Целевая схема:
- **A (primary, запись):** `mtg.ivx.su`
- **B (replica, только чтение):** `gt1.ivx.su`
Изменения вносятся только на A (через API/бот), затем автоматически синхронизируются на B.
## 1) Подготовка `telemt-data` на обоих серверах
```bash
cd /opt/telemt-plus
docker compose stop telemt
mkdir -p telemt-data/cache
```
Если ранее использовались отдельные файлы рядом с compose:
```bash
mkdir -p backup-telemt-$(date +%F-%H%M%S)
cp -a config.toml proxy-secret cache docker-compose.yml backup-telemt-$(date +%F-%H%M%S)/ 2>/dev/null || true
[ -f config.toml ] && cp -f config.toml telemt-data/config.toml
[ -f proxy-secret ] && cp -f proxy-secret telemt-data/proxy-secret
[ -d cache ] && cp -a cache/. telemt-data/cache/
```
Права под пользователя контейнера Telemt (`uid/gid = 999`):
```bash
chown -R 999:999 telemt-data
find telemt-data -type d -exec chmod 750 {} \;
find telemt-data -type f -exec chmod 640 {} \;
chmod 660 telemt-data/config.toml 2>/dev/null || true
chmod 770 telemt-data/cache 2>/dev/null || true
```
## 2) Compose-настройка (A и B)
Для сервиса `telemt` должен быть volume директории:
```yaml
volumes:
- ./telemt-data:/run/telemt
```
Убрать:
- `./config.toml:/run/telemt/config.toml`
- `tmpfs: /run/telemt`
## 3) Настройка API в `config.toml`
### A (`mtg.ivx.su`)
```toml
[server.api]
enabled = true
read_only = false
```
### B (`gt1.ivx.su`)
```toml
[server.api]
enabled = true
read_only = true
```
## 4) SSH-доступ A -> B без пароля
Выполняется на `mtg.ivx.su`:
```bash
ssh-keygen -t ed25519 -N "" -f ~/.ssh/telemt_sync
ssh-copy-id -i ~/.ssh/telemt_sync.pub root@gt1.ivx.su
ssh -i ~/.ssh/telemt_sync root@gt1.ivx.su "echo ok"
```
## 5) Установка `lsyncd` на A (`mtg.ivx.su`)
```bash
apt update && apt install -y lsyncd rsync
mkdir -p /etc/lsyncd
```
Создать файл `/etc/lsyncd/lsyncd.conf.lua`:
```lua
settings {
logfile = "/var/log/lsyncd.log",
statusFile = "/var/log/lsyncd.status",
nodaemon = false,
}
sync {
default.rsyncssh,
source = "/opt/telemt-plus/telemt-data/",
host = "root@gt1.ivx.su",
targetdir = "/opt/telemt-plus/telemt-data/",
delay = 1,
exclude = { "cache/" },
rsync = {
archive = true,
compress = true,
_extra = {
"--delete",
"--chown=999:999",
"--chmod=Du=rwx,Dg=rx,Do=,Fu=rw,Fg=r,Fo=",
"-e", "ssh -i /root/.ssh/telemt_sync -o StrictHostKeyChecking=accept-new"
}
}
}
```
## 6) Первичная синхронизация (один раз)
На `mtg.ivx.su`:
```bash
rsync -az --delete \
--chown=999:999 \
--chmod=Du=rwx,Dg=rx,Do=,Fu=rw,Fg=r,Fo= \
-e "ssh -i /root/.ssh/telemt_sync -o StrictHostKeyChecking=accept-new" \
/opt/telemt-plus/telemt-data/ \
root@gt1.ivx.su:/opt/telemt-plus/telemt-data/
```
## 7) Запуск `lsyncd`
На A:
```bash
systemctl enable lsyncd
systemctl restart lsyncd
systemctl status lsyncd --no-pager
```
Если ошибка пути конфигурации:
```bash
systemctl cat lsyncd
```
## 8) Проверка работы
На обоих серверах:
```bash
cd /opt/telemt-plus
docker compose up -d --force-recreate telemt
docker logs --tail=100 telemt
```
На B проверить режим read-only:
```bash
curl -s http://127.0.0.1:9091/v1/health
```
В ответе ожидается `read_only: true`.
## 9) Правило эксплуатации
- Мутации (`POST/PATCH/DELETE`) делать только на A (`mtg.ivx.su`).
- Бота направлять на API A.
- B (`gt1.ivx.su`) держать как реплику только для чтения.