天天看点

Docker +Django +supervisor部署web服务问题记录

Docker +Django +supervisor部署web服务问题记录

###问题:ModuleNotFoundError: No module named ‘corsheaders’

解决方案:pip install django-cors-headers

###问题:运行docker命令时Error:The input device is not a TTY

解决方案:把docker run -itd 修改为docker run -i

###问题:运行pytorch时 Segmentation Fault 错误

解决方案:torch 版本不匹配。注:torch 1.2.0及以后cpu版本安装时命令为pip install torch+cpu

###问题:Django 跨域问题

解决方案:

1.pip install django-cors-headers

2. setting.py 添加

INSTALLED_APPS = [

‘django.contrib.admin’,

‘django.contrib.auth’,

‘django.contrib.contenttypes’,

‘django.contrib.sessions’,

‘django.contrib.messages’,

‘django.contrib.staticfiles’,

‘corsheaders’,

]

MIDDLEWARE = [

‘django.middleware.security.SecurityMiddleware’,

‘django.contrib.sessions.middleware.SessionMiddleware’,

’corsheaders.middleware.CorsMiddleware’,

‘django.middleware.common.CommonMiddleware’,

‘django.middleware.csrf.CsrfViewMiddleware’,

‘django.contrib.auth.middleware.AuthenticationMiddleware’,

‘django.contrib.messages.middleware.MessageMiddleware’,

‘django.middleware.clickjacking.XFrameOptionsMiddleware’,

]

CORS_ALLOW_CREDENTIALS = True

CORS_ORIGIN_ALLOW_ALL = True

APPEND_SLASH = False

###问题:unlinking stable socket /tmp/supervisor.sock

解决方案:unlink /tmp/supervisor.sock

###问题:supervisord 启动失败 Error: Another program is already listening on a port that one of our HTTP server

解决方案:

ps -ef |grep supervisord

kill -s SIGTERM “PID”