uwsgi
通过Redis队列,实现django(python)和Go之间通信
Heroku 快速搭建 免费高性能 Jupyter Notebook
Step-by-Step Guide to Setting up Django-RQ
Redis queues-RQ消息队列
Redis的LIST结构,具备左进右出功能,使用BRPOP的阻塞弹出,即可以完成一个基本的RedisQueue<T> GetQueue取得队列,enqueue发布消息, get_worker取得消息,指定阻塞时间10秒,如果没有取得,返回为None worker.work()运行消息, 返回结果在worker.result中 LPUSH生产消息(插入列表), BRPOP消费消息(弹出列表)
使用nginx托管django服务的原理 使用uwsgi开启django服务(通过配置文件启动) 防火墙关闭uwsgi端口(uwsgi的websocket一定要使用127.0.0.1的方式配置)) 编写nginx配置文件,通过nginx访问uwsgi,再通过uwsgi访问django
nginx.conf
upstream django { server unix:/app/hkcdBD/docker/app.sock; # server 127.0.0.1:8001; } server { listen 8088 default_server; server_name .example.com; charset utf-8; #设置ssl证书 ssl_certificate /etc/nginx/ssl/certificate.crt; ssl_certificate_key /etc/nginx/ssl/privateKey.key; ssl_ciphers 'AES128+EECDH;AES128+'; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; client_max_body_size 75M; location /media { alias /app/hkcdBD/media; } location /static { alias /app/hkcdBD/static; } location / { uwsgi_pass django; include /app/hkcdBD/docker/uwsgi_params; #自定义超时 uwsgi_read_timeout 120s; uwsgi_send_timeout 120s; } } ----------------------------------------------------- start.sh: uwsgi --ini uwsgi.ini stop.sh uwsgi --stop uwsgi.pid uwsgi.ini设置: [uwsgi] base=/home/dvue projectname=dvue chdir=/home/dvue #module=djangovue.wsgi:application module=djangovue.wsgi:application home=/home/dvue static-map=/static=/home/dvue/djangovue/static # 确保接收非Ascii字符 env = LANG=en_US.UTF-8 #virtualenv = /home/dvue/venv/versions/%n virtualenv = /home/%(projectname) # 指定sock的文件路径 socket=/home/dvue/deploy/uwsgi.sock # 进程个数 workers=5 pidfile=/home/dvue/deploy/uwsgi.pid # 指定IP端口 socket = :9000 #http=127.0.0.1:9000 # 启动uwsgi的用户名和用户组 #uid=root #gid=root # 启用主进程 master=true # 开启进程数量 processes = 3 # 自动移除unix Socket和pid文件当服务停止的时候 vacuum=true # 序列化接受的内容,如果可能的话 thunder-lock=true # 启用线程 enable-threads=true # 设置自中断时间 harakiri=90 http-timeout=120 # 设置缓冲 post-buffering=4096 # 设置日志目录 daemonize=/home/dvue/deploy/uwsgi.log nginx配置: server { listen 8000; server_name localhost; index index.html; root /home/dvue/frontend/dist; #root /home/dvue/front/dist; error_page 404 /404.html; location = /404.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } }