简介

Gunicorn来源于Ruby的unicorn项目,是一个Python WSGI HTTP Server,通过pre-fork worker模型来管理和维护worker。

简而言之就是通过多进程管理应用服务器,实现了对WSGI的功能拓展,比如IO处理模型是同步还是异步、轮询机制、请求限制等等。

配置

参数配置


Supervisor

我们知道Gunicorn是一个wsgi服务器,它通过一个主进程控制、管理请求,但是如果这个主进程挂了怎么办?这就好比我们使用nohup在后台运行一个应用服务器,但是如果主机重启或其他异常导致后台进程挂了,我们是不可能及时重启服务器的。

这时Supervisor就很有用了,Supervisor是一个进程管理软件,它可以根据你的要求执行命令行命令,设置log日志,自动重启挂掉的进程。

通常是Supervisor与Gunicorn一起使用。

配置

# program.conf
[program:<program name>]
command=/usr/local/bin/gunicorn wsgi --bind <ip:port> --workers <2 * cpucores + 1> --worker-class gevent
directory=<program directory>
autostart=true
autorestart=true
stdout_logfile=<stdoutlog directory>
stderr_logfile=<stderrlog directory>

# supervisor 中文 bug
environment=LANG="en_US.utf8", LC_ALL="en_US.UTF-8", LC_LANG="en_US.UTF-8"
# 建立一个软链接
ln -s -f program.conf /etc/supervisor/conf.d/program.conf
# 重启supervisor以开启服务
service supervisor restart

Gunicorn、Supervisor的更多相关文章

  1. 一起学ASP.NET Core 2.0学习笔记(一): CentOS下 .net core2 sdk nginx、supervisor、mysql环境搭建

    作为.neter,看到.net core 2.0的正式发布,心里是有点小激动的,迫不及待的体验了一把,发现速度确实是快了很多,其中也遇到一些小问题,所以整理了一些学习笔记: 阅读目录 环境说明 安装C ...

  2. CentOS,net core2 sdk nginx、supervisor、mysql

    CentOS下 .net core2 sdk nginx.supervisor.mysql环境搭建 作为.neter,看到.net core 2.0的正式发布,心里是有点小激动的,迫不及待的体验了一把 ...

  3. 项目的发布(nginx、uwsgi、django、virtualenv、supervisor)

    导论 WSGI是Web服务器网关接口.它是一个规范,描述了Web服务器如何与Web应用程序通信,以及Web应用程序如何链接在一起以处理一个请求,(接收请求,处理请求,响应请求) 基于wsgi运行的框架 ...

  4. flask,gunicorn,supervisor,nginx配置服务器接口

    1,申请阿里云主机 2,apt-get update 3,apt-get install pip 4,pip install virtualenv 5,virtualenv venv 6,source ...

  5. django 部署,gunicorn、virtualenv、nginx

    声明: 1.本篇文章是我边写命令边写的,请尊重我的劳动成果,转载请加上链接. 2.我既然公开写出来,是希望大家遇到问题的时候有个参考,所以,大家可以免费转载,使用该文章 3.但是,如果你要用这篇文章来 ...

  6. Node.js学习笔记(一) --- HTTP 模块、URL 模块、supervisor 工具

    一.Node.js创建第一个应用 如果我们使用 PHP 来编写后端的代码时,需要 Apache 或者 Nginx 的 HTTP 服务器, 来处理客户端的请求相应.不过对 Node.js 来说,概念完全 ...

  7. 【Storm】核心组件nimbus、supervisor、worker、executor、task

    nimbus 是整个集群的控管核心,负责topology的提交.运行状态监控.任务重新分配等工作. zk就是一个管理者,监控者. 总体描述:nimbus下命令(分配任务),zk监督执行(心跳监控wor ...

  8. ubuntu18.04+gunicorn+nginx+supervisor+mysql+redis安装django项目

    Ubuntu18.04 install Django project 项目准备: ECS 实例 (云服务器) 此安装部署方案适合本地ubuntu18.04系统安装和虚拟机中ubuntu18.04系统安 ...

  9. CentOS7部署Flask+Gunicorn+Nginx+Supervisor

    1. Git客户端 Win10安装git for windows 1.1 设置Git全局参数 打开Git Bash $ git config --global user.name "Alic ...

随机推荐

  1. 524. Longest Word in Dictionary through Deleting

    Given a string and a string dictionary, find the longest string in the dictionary that can be formed ...

  2. Android TextView 中实现部分文字变色以及点击事件

    首先要想实现文字变色以及点击,都需要使用到SpannableStringBuilder,实例化该类也很简单,只需将你想要处理的字符串当做参数 SpannableStringBuilder spanna ...

  3. HDU 6225.Little Boxes-大数加法 (2017ACM/ICPC亚洲区沈阳站-重现赛(感谢东北大学))

    整理代码... Little Boxes Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/O ...

  4. Add and Search Word - Data structure design - LeetCode

    Design a data structure that supports the following two operations: void addWord(word) bool search(w ...

  5. Android 进度条对话框ProgressDialog

    <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...

  6. python局部变量与全局变量

    name = "head first python"def what_happens_here():    print(name)  1    name = "pytho ...

  7. python 工具 字符串转numpy浮点数组

    不同的数字之间使用 空格“ ”,“$”,"*"等隔开,支持带小数点的字符串NumArray=str2num(LineString,comment='#')将字符串中的所有非Doub ...

  8. 有用PHP依赖管理工具Composer新手教程

    PHP依赖管理工具Composer新手教程 Composer 是 PHP 的一个依赖管理工具.它同意你申明项目所依赖的代码库,它会在你的项目中为你安装他们. 依赖管理 Composer 不是一个包管理 ...

  9. 【LeetCode】84. Largest Rectangle in Histogram——直方图最大面积

    Given n non-negative integers representing the histogram's bar height where the width of each bar is ...

  10. vs:如何添加.dll文件

    Newtonsoft.Json.dll  一个第三方的json序列化和反序列化dll,转换成json供页面使用,页面json数据转换成对象,供.net使用 Mysql.Data.dll  mysql数 ...