· 5 years ago · May 03, 2020, 10:14 PM
1Gunicorn.service config:
2
3[Unit]
4Description=gunicorn daemon
5After=network.target
6
7[Service]
8User=hbcradmin
9Group=www-data
10WorkingDirectory=/home/hbcradmin/www/hbcr
11ExecStart=/home/hbcradmin/www/env/bin/gunicorn --access-logfile - --workers 5 --bind 127.0.0.1:8080 hbcr.wsgi:application
12
13[Install]
14WantedBy=multi-user.target
15
16
17
18
19django setting
20
21import os
22
23# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
24BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
25
26
27# Quick-start development settings - unsuitable for production
28# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
29
30# SECURITY WARNING: keep the secret key used in production secret!
31SECRET_KEY = 'e!q5c0^@=atfnsce+wh=-1wpz8a*0@6qt-zm-usc=0ohyodyxc'
32
33# SECURITY WARNING: don't run with debug turned on in production!
34DEBUG = True
35
36ALLOWED_HOSTS = ['hbcr.ru', 'localhost', '127.0.0.1']
37
38
39# Application definition
40
41INSTALLED_APPS = [
42 'django.contrib.admin',
43 'django.contrib.auth',
44 'django.contrib.contenttypes',
45 'django.contrib.sessions',
46 'django.contrib.messages',
47 'django.contrib.staticfiles',
48 'home',
49]
50
51MIDDLEWARE = [
52 'django.middleware.security.SecurityMiddleware',
53 'django.contrib.sessions.middleware.SessionMiddleware',
54 'django.middleware.common.CommonMiddleware',
55 'django.middleware.csrf.CsrfViewMiddleware',
56 'django.contrib.auth.middleware.AuthenticationMiddleware',
57 'django.contrib.messages.middleware.MessageMiddleware',
58 'django.middleware.clickjacking.XFrameOptionsMiddleware',
59]
60
61ROOT_URLCONF = 'hbcr.urls'
62
63TEMPLATES = [
64 {
65 'BACKEND': 'django.template.backends.django.DjangoTemplates',
66 'DIRS': [],
67 'APP_DIRS': True,
68 'OPTIONS': {
69 'context_processors': [
70 'django.template.context_processors.debug',
71 'django.template.context_processors.request',
72 'django.contrib.auth.context_processors.auth',
73 'django.contrib.messages.context_processors.messages',
74 ],
75 },
76 },
77]
78
79WSGI_APPLICATION = 'hbcr.wsgi.application'
80
81
82# Database
83# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
84
85DATABASES = {
86 'default': {
87 'ENGINE': 'django.db.backends.sqlite3',
88 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
89 }
90}
91
92
93# Password validation
94# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
95
96AUTH_PASSWORD_VALIDATORS = [
97 {
98 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
99 },
100 {
101 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
102 },
103 {
104 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
105 },
106 {
107 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
108 },
109]
110
111
112# Internationalization
113# https://docs.djangoproject.com/en/3.0/topics/i18n/
114
115LANGUAGE_CODE = 'en-us'
116
117TIME_ZONE = 'UTC'
118
119USE_I18N = True
120
121USE_L10N = True
122
123USE_TZ = True
124
125
126# Static files (CSS, JavaScript, Images)
127# https://docs.djangoproject.com/en/3.0/howto/static-files/
128
129STATIC_URL = '/static/'
130STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
131STATICFILES_DIRS = (
132 os.path.join(BASE_DIR, 'static'),
133 )