sch
This commit is contained in:
1 parent
98488315fd
commit
8ef36440fc
5 files changed
+247
-9
No files matched your search
@@ -8,6 +8,25 @@
|
|||||||
3. Временная схема - файловая БД SQLITE
|
3. Временная схема - файловая БД SQLITE
|
||||||
4. Redis
|
4. Redis
|
||||||
|
|
||||||
|
## Схема ##
|
||||||
|
```mermaid
|
||||||
|
flowchart TD
|
||||||
|
A[PORTAL COD2] <-->|Запрос к серверу| C{Nginx}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
C <-->|Фронт| F[Vuetify]
|
||||||
|
F-->D[Gunicorn]
|
||||||
|
D <-->|Виртуальное окружение | E{manage.py}
|
||||||
|
|
||||||
|
E --> |К БД портала| P[PostgreSQL -- пока dbsqlite]
|
||||||
|
E-->|Сервер Авторизации|G[10.252.44.13]
|
||||||
|
G <-->|Active directory|AD
|
||||||
|
G <--> |БД Справочника| J[БД 10.252.44.33]
|
||||||
|
C <--> H[Daphne]
|
||||||
|
H <--> I[Redis]
|
||||||
|
E <--> I
|
||||||
|
```
|
||||||
|
|
||||||
## Установка и настройка ##
|
## Установка и настройка ##
|
||||||
|
|
||||||
@@ -15,7 +34,7 @@
|
|||||||
|
|
||||||
1. В каталоге проекта Создаем окружение
|
1. В каталоге проекта Создаем окружение
|
||||||
|
|
||||||
``` python -m venv env ```
|
``` python3.10 -m venv env ```
|
||||||
|
|
||||||
2. Активируем окружение
|
2. Активируем окружение
|
||||||
|
|
||||||
@@ -30,13 +49,15 @@
|
|||||||
|
|
||||||
``` cd ../src/```
|
``` cd ../src/```
|
||||||
|
|
||||||
5. В зависимости от настраиваемого сервера, меняем конфигурацию подключений к БД в файле back/conf.py
|
5. В каталог src разархивируем portal.zip из sys
|
||||||
Тестовая бд живет на том же сервере, что и проект (60)
|
Бд живет на том же сервере, что и проект (60)
|
||||||
Рабочая же соединяется с 33
|
|
||||||
|
Прописываем подключения в settings.py
|
||||||
|
|
||||||
|
|
||||||
6. Для проверки запускаем сервер разработки
|
6. Для проверки запускаем сервер разработки
|
||||||
|
|
||||||
```python main.py```
|
```python manage.py runserver```
|
||||||
|
|
||||||
Если в консоли не появляются ошибки и сервер стартует, переходим далее. В противном случае - доустанавливаем необходимые пакеты.
|
Если в консоли не появляются ошибки и сервер стартует, переходим далее. В противном случае - доустанавливаем необходимые пакеты.
|
||||||
|
|
||||||
@@ -45,15 +66,20 @@
|
|||||||
На этом работы непосредственно с бэкэндом завершены
|
На этом работы непосредственно с бэкэндом завершены
|
||||||
### Порты ###
|
### Порты ###
|
||||||
|
|
||||||
Quasar на тестовом : 8002
|
Vuetify : 9966
|
||||||
|
Gunicorn: 9965
|
||||||
|
Daphnr: 9967
|
||||||
|
|
||||||
### Настройка NGINX, GUNICORN, Quasar ###
|
### Настройка NGINX, GUNICORN, Vuetify, Daphne ###
|
||||||
В каталоге sys расположены примерные файлы конфигов для тестового и боевого серверов
|
В каталоге sys расположены примерные файлы конфигов для тестового и боевого серверов
|
||||||
|
|
||||||
При копировании убедиться, что пути соответствуют системе
|
При копировании убедиться, что пути соответствуют системе
|
||||||
#### NGINX + Quasar ####
|
#### NGINX Vuetify ####
|
||||||
Стандартный путь для файлов .conf
|
Стандартный путь для файлов .conf
|
||||||
/etc/nginx/sites-enabled
|
/etc/nginx/sites-enabled
|
||||||
|
|
||||||
|
|
||||||
[Схема репозиториев](REPOS.md)
|
#### GUNICORN, Daphne ####
|
||||||
|
|
||||||
|
Файлы .service кладем в каталог /etc/systemd/system
|
||||||
|
|
||||||
File renamed without changes.
+150
@@ -0,0 +1,150 @@
|
|||||||
|
|
||||||
|
|
||||||
|
# Daphne, Django channels backend
|
||||||
|
upstream portal-backend {
|
||||||
|
server 127.0.0.1:9967;
|
||||||
|
}
|
||||||
|
|
||||||
|
#Flask backend for UKD Wizard
|
||||||
|
#
|
||||||
|
#upstream wizard-backend {
|
||||||
|
# server 10.252.44.60:8888;
|
||||||
|
# }
|
||||||
|
|
||||||
|
# PORTAL Test server
|
||||||
|
server {
|
||||||
|
|
||||||
|
listen 9966;
|
||||||
|
server_name 9966;
|
||||||
|
|
||||||
|
|
||||||
|
send_timeout 600;
|
||||||
|
proxy_connect_timeout 600;
|
||||||
|
proxy_send_timeout 600;
|
||||||
|
proxy_read_timeout 600;
|
||||||
|
|
||||||
|
root /var/www/PORTAL_COD2/front/dist/;
|
||||||
|
include /etc/nginx/mime.types;
|
||||||
|
access_log /var/log/nginx/portal.access.log;
|
||||||
|
error_log /var/log/nginx/portal.error.log;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri /index.html;
|
||||||
|
}
|
||||||
|
|
||||||
|
# location ~ ^.*/static/(.+\.xlsx)/$ {
|
||||||
|
# alias /var/www/portal/portal/static;
|
||||||
|
# }
|
||||||
|
|
||||||
|
location /static {
|
||||||
|
autoindex on;
|
||||||
|
alias /var/www/PORTAL_COD2/portal/static/;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /media {
|
||||||
|
alias /var/www/PORTAL_COD2/portal/media;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
location ^~ /api/ {
|
||||||
|
client_max_body_size 100m;
|
||||||
|
include proxy_params;
|
||||||
|
proxy_pass http://127.0.0.1:8085;
|
||||||
|
}
|
||||||
|
# error_page 500 502 503 504 /500.html;
|
||||||
|
# location = /500.html {
|
||||||
|
# root /var/www/proj/;
|
||||||
|
# internal;
|
||||||
|
# }
|
||||||
|
# location /testing {
|
||||||
|
# fastcgi_pass unix:/does/not/exit;
|
||||||
|
#}
|
||||||
|
# VS 20220530 - Test reverse proxy for statistics as susbsite
|
||||||
|
## location /stat {
|
||||||
|
## rewrite ^/stat(.*) /$1 break;
|
||||||
|
# proxy_set_header Host "stat";
|
||||||
|
### 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;
|
||||||
|
### autoindex on;
|
||||||
|
#
|
||||||
|
### proxy_pass http://127.0.0.1:8080;
|
||||||
|
### }
|
||||||
|
|
||||||
|
|
||||||
|
location /ws/ {
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection "upgrade";
|
||||||
|
proxy_redirect off;
|
||||||
|
proxy_pass http://portal-backend;
|
||||||
|
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-Host $server_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Wizard integration
|
||||||
|
# vs@20220831
|
||||||
|
#location /wizard/ {
|
||||||
|
# proxy_http_version 1.1;
|
||||||
|
# proxy_set_header Upgrade $http_upgrade;
|
||||||
|
# proxy_set_header Connection "upgrade";
|
||||||
|
#proxy_redirect off;
|
||||||
|
# proxy_set_header Host $host;
|
||||||
|
#proxy_set_header Host $http_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-Host $server_name;
|
||||||
|
# proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
# proxy_pass http://wizard-backend/;
|
||||||
|
#proxy_pass http://wizard-backend/wizard;
|
||||||
|
# include proxy_params;
|
||||||
|
# }
|
||||||
|
##location /_next/ {
|
||||||
|
## proxy_http_version 1.1;
|
||||||
|
## proxy_set_header Upgrade $http_upgrade;
|
||||||
|
## proxy_set_header Connection "upgrade";
|
||||||
|
## #proxy_redirect off;
|
||||||
|
## proxy_set_header Host $host;
|
||||||
|
#proxy_set_header Host $http_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-Host $server_name;
|
||||||
|
## proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
## proxy_pass http://wizard-backend/;
|
||||||
|
## #proxy_pass http://wizard-backend/wizard;
|
||||||
|
# include proxy_params;
|
||||||
|
## }
|
||||||
|
|
||||||
|
# Test redirection - all works fine.
|
||||||
|
# http://ukt/node-red/ -> http://10.252.44.35:1880/
|
||||||
|
# vs@20220831
|
||||||
|
## location /node-red/ {
|
||||||
|
## proxy_http_version 1.1;
|
||||||
|
## proxy_set_header Upgrade $http_upgrade;
|
||||||
|
## proxy_set_header Connection "upgrade";
|
||||||
|
## proxy_set_header Host 10.252.44.35;
|
||||||
|
## 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_pass http://10.252.44.35:1880/;
|
||||||
|
## }
|
||||||
|
# Does not work
|
||||||
|
##location ^~ /wiki/ {
|
||||||
|
## proxy_http_version 1.1;
|
||||||
|
## proxy_set_header Upgrade $http_upgrade;
|
||||||
|
## proxy_set_header Connection "upgrade";
|
||||||
|
## proxy_redirect off;
|
||||||
|
## #proxy_set_header Host $host;
|
||||||
|
## #proxy_set_header Host $http_host;
|
||||||
|
## proxy_set_header Host wiki.cod2.regions.tax.nalog.ru;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=gunicorn daemon
|
||||||
|
Requires=gunicorn.socket
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
User=root
|
||||||
|
#WorkingDirectory=/var/www/proj/DQM/dqmback
|
||||||
|
WorkingDirectory=/var/www/PORTAL_COD2
|
||||||
|
# --timeout NNN - set timeout for gunicorn to NNN sec, default - 30sec
|
||||||
|
# --access-logfile FILENAME - log all requests to file FILENAMEA
|
||||||
|
# --error-logfile FILENAME - set error log file to FILENAME
|
||||||
|
# Формат лог-файла кастомизируется, детали - в документации
|
||||||
|
# --capture-output - redirect stdout/stderr to error-logfile
|
||||||
|
# --log-syslog - send Gunicorn logs to Syslog
|
||||||
|
# -log-syslog-prefix SYSLOG_PREFIX - set Syslog Prefix
|
||||||
|
# --log-syslog-facility SYSLOG_FACILITY - set Syslog Facility, default - user(?-да, так в документации)
|
||||||
|
# правильно пользовать local1..local7
|
||||||
|
# --log-level=debug - set debug logging
|
||||||
|
# levels: debug info warning error critical
|
||||||
|
# details: https://docs.gunicorn.org/en/stable/settings.html#logging
|
||||||
|
# --workers N - set number of workers to N
|
||||||
|
# --bind unix:FILENAME - bind to unix socket with name FILENAME
|
||||||
|
# --bind unix:/run/gunicorn.sock
|
||||||
|
# --bind=127.0.0.1:9000 - bind to TCP socket 127.0.0.1:9000
|
||||||
|
# default listen socket: 127.0.0.1:8000
|
||||||
|
# --pid=PIDFILE - user file PIDFILE as PID File
|
||||||
|
#
|
||||||
|
# Howto debug NGinx+Gunicorn: https://mattsegal.dev/django-gunicorn-nginx-logging.html
|
||||||
|
#
|
||||||
|
#ExecStart=/usr/bin/gunicorn --workers 3 --bind unix:/var/www/application.sock wsgi:app
|
||||||
|
|
||||||
|
|
||||||
|
#ExecStart=/var/www/sup/env/bin/uvicorn \
|
||||||
|
ExecStart=/var/www/PORTAL_COD2/env/bin/gunicorn portal.wsgi:application --bind 10.252.44.60:9965 --workers 4 --error-logfile /var/log/portal/portal.error.log
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# --access-logfile /var/log/gun-ukt/gun-ukt.access.log \
|
||||||
|
# --workers 3 \
|
||||||
|
# --timeout 600 \
|
||||||
|
# --bind unix:/run/gunicorn.sock \
|
||||||
|
# --limit-request-line 0 \
|
||||||
|
# dqmback.wsgi:application
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=WebSocket Daphne Service for PORTAL_COD2-t
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
User=root
|
||||||
|
#Group = nginx
|
||||||
|
WorkingDirectory=/var/www/PORTAL_COD2
|
||||||
|
ExecStart=/var/www/PORTAL_COD2/env/bin/python /var/www/PORTAL_COD2/env/bin/daphne -p 9967 portal.asgi:application
|
||||||
|
Restart=on-failure
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
Reference in new issue
Block a user