fix deploy issues

- make supervisorctl happy
 - fix avatar path
 - refine logging config
 - add nginx buffer path
This commit is contained in:
virusdefender 2017-11-26 10:40:56 +08:00
parent 00eb3b1967
commit 1bf4973648
5 changed files with 50 additions and 57 deletions

View File

@ -1,5 +1,5 @@
location /public { location /public {
root /app/data; root /data;
} }
location /api { location /api {

View File

@ -20,6 +20,7 @@ http {
gzip on; gzip on;
gzip_vary on; gzip_vary on;
gzip_types application/javascript text/css; gzip_types application/javascript text/css;
client_body_temp_path /tmp 1 2;
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" ' '$status $body_bytes_sent "$http_referer" '

View File

@ -29,4 +29,4 @@ do
done done
chown -R nobody:nogroup $DATA $APP/dist chown -R nobody:nogroup $DATA $APP/dist
exec supervisord -c /app/deploy/supervisor.conf exec supervisord -c /app/deploy/supervisord.conf

View File

@ -1,20 +1,26 @@
[supervisord] [supervisord]
logfile=/app/data/log/supervisord.log logfile=/data/log/supervisord.log
logfile_maxbytes=10MB logfile_maxbytes=10MB
logfile_backups=10 logfile_backups=10
loglevel=info loglevel=info
pidfile=/tmp/supervisord.pid pidfile=/tmp/supervisord.pid
nodaemon=true nodaemon=true
childlogdir=/app/data/log/ childlogdir=/data/log/
[inet_http_server]
port=127.0.0.1:9005
[rpcinterface:supervisor]
supervisor.rpcinterface_factory=supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl] [supervisorctl]
serverurl=unix:///tmp/supervisor.sock serverurl=http://127.0.0.1:9005
[program:nginx] [program:nginx]
command=nginx -c /app/deploy/nginx/nginx.conf command=nginx -c /app/deploy/nginx/nginx.conf
directory=/app/ directory=/app/
stdout_logfile=/app/data/log/nginx.log stdout_logfile=/data/log/nginx.log
stderr_logfile=/app/data/log/nginx.log stderr_logfile=/data/log/nginx.log
autostart=true autostart=true
autorestart=true autorestart=true
startsecs=5 startsecs=5
@ -25,8 +31,8 @@ killasgroup=true
command=sh -c "gunicorn oj.wsgi --user nobody -b 127.0.0.1:8080 --reload -w `grep -c ^processor /proc/cpuinfo`" command=sh -c "gunicorn oj.wsgi --user nobody -b 127.0.0.1:8080 --reload -w `grep -c ^processor /proc/cpuinfo`"
directory=/app/ directory=/app/
user=nobody user=nobody
stdout_logfile=/app/data/log/gunicorn.log stdout_logfile=/data/log/gunicorn.log
stderr_logfile=/app/data/log/gunicorn.log stderr_logfile=/data/log/gunicorn.log
autostart=true autostart=true
autorestart=true autorestart=true
startsecs=5 startsecs=5
@ -37,8 +43,8 @@ killasgroup=true
command=celery -A oj worker -l warning command=celery -A oj worker -l warning
directory=/app/ directory=/app/
user=nobody user=nobody
stdout_logfile=/app/data/log/celery.log stdout_logfile=/data/log/celery.log
stderr_logfile=/app/data/log/celery.log stderr_logfile=/data/log/celery.log
autostart=true autostart=true
autorestart=true autorestart=true
startsecs=5 startsecs=5

View File

@ -125,54 +125,40 @@ UPLOAD_DIR = f"{DATA_DIR}{UPLOAD_PREFIX}"
STATICFILES_DIRS = [os.path.join(DATA_DIR, "public")] STATICFILES_DIRS = [os.path.join(DATA_DIR, "public")]
LOGGING = { LOGGING = {
'version': 1, 'version': 1,
'disable_existing_loggers': False, 'disable_existing_loggers': False,
'formatters': { 'formatters': {
'standard': { 'standard': {
'format': '%(asctime)s [%(threadName)s:%(thread)d] [%(name)s:%(lineno)d] [%(module)s:%(funcName)s] [%(levelname)s]- %(message)s', 'format': '[%(asctime)s] - [%(levelname)s] - [%(name)s:%(lineno)d] - %(message)s',
'datefmt': '%Y-%m-%d %H:%M:%S' 'datefmt': '%Y-%m-%d %H:%M:%S'
} }
}, },
'handlers': { 'handlers': {
'django_error': { 'console': {
'level': 'WARNING', 'level': 'DEBUG',
'class': 'logging.handlers.RotatingFileHandler', 'class': 'logging.StreamHandler',
'filename': os.path.join(LOG_PATH, 'django.log'), 'formatter': 'standard'
'formatter': 'standard' }
}, },
'app_info': { 'loggers': {
'level': 'INFO', 'django.request': {
'class': 'logging.handlers.RotatingFileHandler', 'handlers': ['console'],
'filename': os.path.join(LOG_PATH, 'app_info.log'), 'level': 'ERROR',
'formatter': 'standard' 'propagate': True,
}, },
'console': { 'django.db.backends': {
'level': 'DEBUG', 'handlers': ['console'],
'class': 'logging.StreamHandler', 'level': 'ERROR',
'formatter': 'standard' 'propagate': True,
} },
}, '': {
'loggers': { 'handlers': ['console'],
'django.request': { 'level': 'WARNING',
'handlers': ['django_error', 'console'], 'propagate': True,
'level': 'WARNING', }
'propagate': True, },
},
'django.db.backends': {
'handlers': ['django_error', 'console'],
'level': 'WARNING',
'propagate': True,
},
},
} }
app_logger = {
'handlers': ['app_info', 'console'],
'level': 'DEBUG',
'propagate': False
}
LOGGING["loggers"].update({app: deepcopy(app_logger) for app in LOCAL_APPS})
REST_FRAMEWORK = { REST_FRAMEWORK = {
'TEST_REQUEST_DEFAULT_FORMAT': 'json', 'TEST_REQUEST_DEFAULT_FORMAT': 'json',