From f14bb9995c13a48a88d78fd77fb0d976baaf0ded Mon Sep 17 00:00:00 2001 From: Vic Date: Tue, 30 Jun 2026 11:22:38 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20README.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 87 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f00f4f2..c799942 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,89 @@ # ParleyChat -простой чат, можно обмениваться только текстом \ No newline at end of file +простой чат, можно обмениваться только текстом + +### Рекомендации +- настроить админа в бд в методе initDB() +- очиститьь переменные на всякий случай +```bash +$env:GOOS = "linux" +$env:GOARCH = "amd64" +$env:CGO_ENABLED = "0" +``` +- сбилдить бинарник +```bash +go build -o parley main.go +``` + +- положить на сервер +- сделать его исполняемым +- написать к нему сервис и сделать enabled(см. сервис) +- настроить nginx(конфиг) +- дать nginx разрешение на чтение файлов фронта (в зависимости от того где лежит приложение - ```sudo chmod -R 755 /opt/parley/static/ и sudo chown -R www-data:www-data /opt/parley/static/ ```) +- установить sqlite: apt-get install -y sqlite3 +- начать использвать + +### конфиги +#### nginx /etc/nginx/sites-available/default +- СДЕЛАЙ БЭКАП ПРЕЖДЕ ЧЕМ ЧТО-ТО ДЕЛАТЬ!!!!! +```bash +# --- PARLEY CHAT --- + location = /parley { + return 301 /parley/; + } + + location /parley/ { + proxy_pass http://127.0.0.1:3100/parley/; + proxy_http_version 1.1; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-Prefix /parley; + } + + location /parley/static/ { + alias /opt/parley/static/; + expires 30d; + add_header Cache-Control "public, immutable"; + } + # --- PARLEY CHAT END --- +``` +- проверь что изменения в nginx применились успешно и перезагрузи +```bash +sudo nginx -t +sudo systemctl reload nginx +``` +#### сервис +```bash +sudo nano /etc/systemd/system/parley.service +``` + +```ini +[Unit] +Description=Parley Chat Service +After=network.target + +[Service] +Type=simple +User=root +WorkingDirectory=/opt/parley +Environment="BASE_PATH=/parley" +ExecStart=/opt/parley/parley +Restart=always +RestartSec=5 + +[Install] +WantedBy=multi-user.target +``` +##### запуск сервиса +```bash +sudo systemctl daemon-reload +sudo systemctl enable parley +sudo systemctl start parley +sudo systemctl status parley + +# проверим что слушает порт +sudo netstat -tlnp | grep 3100 +``` +