изменил настройки проекта

This commit is contained in:
Mike0001-droid 2024-05-30 22:10:25 +05:00
parent f5d58ee87a
commit 250c08b326
280 changed files with 238 additions and 61 deletions

38
conf.dev/nginx.conf Normal file
View File

@ -0,0 +1,38 @@
upstream it-radio-uwsgi {
server unix:///usr/local/flexites/projects_ext/it-radio/var/run/uwsgi.sock;
}
server {
listen 80;
access_log /usr/local/flexites/projects_ext/it-radio/var/log/nginx.access.log main;
error_log /usr/local/flexites/projects_ext/id-radio/var/log/nginx.error.log;
location / {
root /usr/local/flexites/projects_ext/it-radio/client/dist;
index index.html;
access_log off;
expires 0;
}
location /api {
root /usr/local/flexites/projects_ext/it-radio/server/proj;
uwsgi_pass it-radio-uwsgi;
include uwsgi_params;
uwsgi_read_timeout 60s;
uwsgi_send_timeout 60s;
}
location /media {
alias /usr/local/flexites/projects_ext/it-radio/server/proj/media;
access_log off;
expires 0;
}
location /static {
alias /usr/local/flexites/projects_ext/it-radio/server/proj/static;
access_log off;
expires 0;
}
}

View File

@ -0,0 +1,19 @@
[program:it-radio-uwsgi]
command = /usr/local/flexites/projects_ext/it-radio/server/env/bin/uwsgi --ini /usr/local/flexites/projects_ext/it-radio/conf.dev/uwsgi.ini
user = www-data
stdout_logfile = /usr/local/flexites/projects_ext/it-radio/var/log/uwsgi.log
stdout_logfile_maxbytes = 10MB
stderr_logfile = /usr/local/flexites/projects_ext/it-radio/var/log/uwsgi.error.log
stderr_logfile_maxbytes = 10MB
startsecs = 0
autostart = true
autorestart = true
redirect_stderr = false
priority = 999
stopsignal = QUIT

21
conf.dev/uwsgi.ini Normal file
View File

@ -0,0 +1,21 @@
[uwsgi]
socket = /usr/local/flexites/projects_ext/it-radio/var/run/uwsgi.sock
pythonpath = /usr/local/flexites/projects_ext/it-radio/server/proj/
module = conf.wsgi
uid = www-data
gid = www-data
chmod-socket = 666
virtualenv = /usr/local/flexites/projects_ext/it-radio/server/env
env = LANG=ru_RU.UTF-8
processes = 2
master = true
max-requests = 1000
harakiri = 60
http-timeout = 60
socket-timeout = 60
no-orphans = true
reload-mercy = 8
touch-reload = /usr/local/flexites/projects_ext/it-radio/var/run/reload
post-buffering = 8192
buffer-size = 32768
uid = 33

View File

@ -0,0 +1,29 @@
import logging
import sentry_sdk
from sentry_sdk.integrations.django import DjangoIntegration
from sentry_sdk.integrations.logging import LoggingIntegration
SENTRY_CONFIG = {
'dsn': "https://8b9022772a4e46eb80bee3d16f28fb86@jora.flexites.org/7",
'integrations': [
DjangoIntegration(),
LoggingIntegration(
level=logging.INFO, # Capture info and above as breadcrumbs
event_level=logging.ERROR # Send errors as events
),
LoggingIntegration(
level=logging.INFO, # Capture info and above as breadcrumbs
event_level=logging.WARNING # Send errors as events
)
],
'traces_sample_rate': 1.0,
'send_default_pii': True,
'environment': 'production'
}
def sentry_start(sentry_config=None):
if sentry_config is None:
sentry_config = SENTRY_CONFIG
return sentry_sdk.init(sentry_config)

View File

@ -0,0 +1 @@
from .development import *

View File

@ -0,0 +1 @@
from .production import *

View File

@ -0,0 +1 @@
from .base import *

View File

@ -1,49 +1,26 @@
"""
Django settings for ITRadioBackend project.
Generated by 'django-admin startproject' using Django 5.0.4.
For more information on this file, see
https://docs.djangoproject.com/en/5.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/5.0/ref/settings/
"""
from pathlib import Path from pathlib import Path
import os import os
# Build paths inside the project like this: BASE_DIR / 'subdir'. # Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent BASE_DIR = Path(__file__).resolve().parent.parent
ROOT_DIR = BASE_DIR.parent.parent.parent
PROJECT_DIR = BASE_DIR.parent
LOG_ROOT = ROOT_DIR / 'var' / 'log'
RUN_ROOT = ROOT_DIR / 'var' / 'run'
TMP_ROOT = ROOT_DIR / 'var' / 'tmp'
# Quick-start development settings - unsuitable for production MEDIA_ROOT = PROJECT_DIR / 'media'
# See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/ MEDIA_URL = 'media/'
STATIC_ROOT = PROJECT_DIR / 'static'
STATIC_URL = 'static/'
# SECURITY WARNING: keep the secret key used in production secret! # SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-z242=*-knp4h=0l1*o-nyid^y0bwt4bvg3tf*wvr(qszj&!8$c' SECRET_KEY = 'django-insecure-z242=*-knp4h=0l1*o-nyid^y0bwt4bvg3tf*wvr(qszj&!8$c'
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False DEBUG = True
if DEBUG:
ALLOWED_HOSTS = ['*']
else:
ALLOWED_HOSTS = ['83.147.244.32', 'localhost']
STATIC_URL = '/static/'
if DEBUG:
STATIC_DIR = os.path.join(BASE_DIR, 'static')
STATICFILES_DIRS = [
STATIC_DIR,
'/var/www/static/',
]
else:
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
MEDIA_URL = '/media/'
ALLOWED_HOSTS = ['*']
CORS_ORIGIN_ALLOW_ALL = True
# Application definition # Application definition
@ -65,6 +42,9 @@ INSTALLED_APPS = [
'rubricks', 'rubricks',
'loginApi', 'loginApi',
'userProfile', 'userProfile',
'sheduler',
'audio',
'api'
] ]
@ -79,7 +59,7 @@ MIDDLEWARE = [
'corsheaders.middleware.CorsMiddleware', 'corsheaders.middleware.CorsMiddleware',
] ]
ROOT_URLCONF = 'ITRadioBackend.urls' ROOT_URLCONF = 'conf.urls'
TEMPLATES = [ TEMPLATES = [
{ {
@ -97,22 +77,7 @@ TEMPLATES = [
}, },
] ]
WSGI_APPLICATION = 'ITRadioBackend.wsgi.application' WSGI_APPLICATION = 'conf.wsgi.application'
# Database
# https://docs.djangoproject.com/en/5.0/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
# Password validation
# https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [ AUTH_PASSWORD_VALIDATORS = [
{ {
@ -141,17 +106,74 @@ USE_I18N = True
USE_TZ = True USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/5.0/howto/static-files/
STATIC_URL = 'static/'
# Default primary key field type
# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
ROTATE_LOG_SIZE = 15 * 1024 * 1024
ROTATE_LOG_COUNT = 10
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'verbose': {
'format': '{levelname} {asctime} {module}:{lineno} {message}',
'style': '{',
'datefmt': '%Y-%m-%d %H:%M:%S',
},
'extended': {
'format': '{levelname} {asctime} {message}',
'style': '{',
'datefmt': '%Y-%m-%d %H:%M:%S',
},
'simple': {
'format': '{levelname} {message}',
'style': '{',
},
},
'handlers': {
'update_history': {
'level': 'DEBUG',
'class': 'logging.handlers.RotatingFileHandler',
'filename': LOG_ROOT / 'update_history.log',
'formatter': 'extended',
'maxBytes': ROTATE_LOG_SIZE,
'backupCount': ROTATE_LOG_COUNT,
},
'upload_media': {
'level': 'DEBUG',
'class': 'logging.handlers.RotatingFileHandler',
'filename': LOG_ROOT / 'upload_media.log',
'formatter': 'extended',
'maxBytes': ROTATE_LOG_SIZE,
'backupCount': ROTATE_LOG_COUNT,
},
'banking': {
'level': 'DEBUG',
'class': 'logging.handlers.RotatingFileHandler',
'filename': LOG_ROOT / 'banking.log',
'formatter': 'extended',
'maxBytes': ROTATE_LOG_SIZE,
'backupCount': ROTATE_LOG_COUNT,
},
},
'loggers': {
'update_history': {
'handlers': ['update_history', ],
'level': 'INFO',
'propagate': False,
},
'upload_media': {
'handlers': ['upload_media', ],
'level': 'INFO',
'propagate': False,
},
'banking': {
'handlers': ['banking'],
'level': 'INFO',
'propagate': False,
},
},
}
REST_FRAMEWORK = { REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': [ 'DEFAULT_PERMISSION_CLASSES': [
@ -163,6 +185,7 @@ REST_FRAMEWORK = {
), ),
'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema' 'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema'
} }
CORS_ALLOWED_ORIGINS = [ CORS_ALLOWED_ORIGINS = [
'http://localhost:5173', # Adjust the port if your Vue app is served on a different one 'http://localhost:5173', # Adjust the port if your Vue app is served on a different one
'http://127.0.0.1:5173', 'http://127.0.0.1:5173',

View File

@ -0,0 +1,22 @@
import sys
from .base import *
DEBUG = True
ALLOWED_HOSTS = ['*']
# Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
REST_FRAMEWORK['DEFAULT_PERMISSION_CLASSES'] = ('rest_framework.permissions.AllowAny',)
if len(sys.argv) >= 2 and not sys.argv[0].endswith('manage.py'):
from conf.sentry import sentry_start, SENTRY_CONFIG
SENTRY_CONFIG['environment'] = 'development'
sentry_start(SENTRY_CONFIG)

View File

@ -0,0 +1,22 @@
import sys
from .base import *
DEBUG = False
ALLOWED_HOSTS = ['*']
# Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
""" DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'ldirect',
'USER': 'flexites',
'PASSWORD': 'flexites',
'HOST': 'localhost',
},
} """
if len(sys.argv) >= 2 and sys.argv[1] != 'runserver':
from conf.sentry import sentry_start, SENTRY_CONFIG
sentry_start(SENTRY_CONFIG)

Some files were not shown because too many files have changed in this diff Show More