supervisor部署tornado
- supervisord常见命令
supervisorctl shutdown 关闭命令 supervisord -c /etc/supervisord.conf 启动supervisord supervisorctl restart all // 重启所有 supervisorctl restart program-name // 重启某一进程,program-name为[program:xx]中的xx supervisorctl status //查看supervisord状态
- 生成配置文件
echo_supervisord_conf > /etc/supervisord.conf
- 编辑配置文件
由于配置文件生成在etc目录下,我们要做进一步配置
带有;的行是被注释的,并不真正发挥作用
[program:olddream]
command=python3 /dingshub/olddream/server.py --port=
; 注意上面一行配置,由于我在linux为python建立的软链接名为python3,各程序员实践的时候需要按照情况作调整
;process_name=%(program_name)s ; process_name expr (default %(program_name)s)
;numprocs= ; number of processes copies to start (def )
directory=/dingshub/olddream/ ; 网站文件夹实际路径,这一路经下放着tornado的起始配置文件server.py
;umask= ; umask for process (default None)
;priority= ; the relative start priority (default )
autostart=true ; start at supervisord start (default: true)
;autorestart=unexpected ; whether/when to restart (default: unexpected)
;startsecs= ; number of secs prog must stay running (def. )
;startretries= ; max # of serial start failures (default )
;exitcodes=, ; 'expected' exit codes for process (default ,)
;stopsignal=QUIT ; signal used to kill process (default TERM)
;stopwaitsecs= ; max num secs to wait b4 SIGKILL (default )
;stopasgroup=false ; send stop signal to the UNIX process group (default false)
;killasgroup=false ; SIGKILL the UNIX process group (def false)
;user=chrism ; setuid to this UNIX account to run the program
redirect_stderr=true ; redirect proc stderr to stdout (default false)
stdout_logfile=/dingshub/olddream/dings.log ; 最好设置一个log日志文件
;stdout_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB)
;stdout_logfile_backups= ; # of stdout logfile backups (default )
;stdout_capture_maxbytes=1MB ; number of bytes in 'capturemode' (default )
;stdout_events_enabled=false ; emit events on stdout writes (default false)
;stderr_logfile=/a/path ; stderr log path, NONE for none; default AUTO
;stderr_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB)
;stderr_logfile_backups= ; # of stderr logfile backups (default )
;stderr_capture_maxbytes=1MB ; number of bytes in 'capturemode' (default )
;stderr_events_enabled=false ; emit events on stderr writes (default false)
;environment=A="",B="" ; process environment additions (def no adds)
;serverurl=AUTO ; override serverurl computation (childutils)
loglevel=info ; 这是一个中等级别的日志
- nginx配置(一个地址多个站点)
分站点配置---这是tornado网站的配置细节 我的nginx是通过编译源代码安装的,在nginx的安装目录下,新建一个vhosts文件夹(如果没有的话)
在vhosts文件夹下建立以 .conf为后缀的文件
例如:
upstream tornados{
server 127.0.0.1:8989; #可以发现这里8989端口与supervisord中的端口一致
server 127.0.0.1:8021;
server 127.0.0.1:8022;
}
proxy_next_upstream error;
server {
listen 8989;
server_name sniffcpcssocks.com;
root /dingshub/olddream;
index server.py;
# 静态文件直接由Nginx处理
location /static/{
alias /data/web/advance_python/tornado_asyn/img/;
expires 24h;
}
location /{
proxy_pass_header Server;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
# 把请求方向代理传给tornado服务器,负载均衡
proxy_pass http://tornados;
}
}
- nginx conf文件夹下 nginx.conf主文件配置(我也并不了解nginx配置要诀---这种配置起码可以保证网站跑起来)
worker_processes ;
events {
worker_connections ;
}
http {
include mime.types;
default_type application/octet-stream;
include /nginx/vhosts/*.conf; #这一句是一个ip地址,多个站点配置的关键
sendfile on;
keepalive_timeout 65;
server {
listen 8999;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
- tornado网站主程序文件server.py(注意!这一程序文件里,不要出现任何注释符号,还有中文,因为supervisord执行时可能会出现异常)
import tornado.ioloop
import tornado.web
import tornado.httpserver
import os
..........
settings={
'template_path':os.path.join(os.getcwd(),"templates"),
'static_path':os.getcwd()+"//templates//static"
}
def App():
return tornado.web.Application([
(r'/loadcolspage',loadcolspage),
.........
(r'/xsfp/list', xsfp_v)],**settings)
if __name__=="__main__":
app = App()
print(("current_path:"),os.path.join(os.getcwd()+"//templates",'static'))
myserver = tornado.httpserver.HTTPServer(app)
myserver.listen()
tornado.ioloop.IOLoop.current().start()
supervisor部署tornado的更多相关文章
- 第八章:部署Tornado
到目前为止,为了简单起见,在我们的例子中都是使用单一的Tornado进程运行的.这使得测试应用和快速变更非常简单,但是这不是一个合适的部署策略.部署一个应用到生产环境面临着新的挑战,既包括最优化性能, ...
- supervisor 部署文档
supervisor 部署文档 supervisor 需要Python支持,如果不用系统的supervisor,单独安装python python 安装 #依赖 yum install python- ...
- flask +gevent+nginx+Gunicorn+supervisor部署flask应用
上篇 可以完美部署flask ,但是视乎在结合gevent+apscheduler 实现异步非阻塞后台和定时任务的时候视乎不是那么完美.请教了前辈,决定使用flask+gevent+nginx+g ...
- CentOS 下部署Nginx+Gunicorn+Supervisor部署Flask项目
原本之前有一部分东西是在Windows Server,但是由于Gunicorn不支持Windows部署起来颇为麻烦.最近转战CentOS,折腾一段时间,终于简单部署成功.CentOS新手,作为一个总结 ...
- Linux+Nginx+Supervisor部署ASP.NET Core实操手册
一.课程介绍 在上一节课程<ASP.NET Core托管和部署Linux实操演练手册>中我们学过net core的部署方式多样性和灵活性.我们通过远程工具输入dotnet 程序集名称.dl ...
- flask+uwsgi+supervisor部署流程
背景: 小鱼最近搞了个工程,python用的2.7(用3也可以),后端使用的是flask,服务器用的linux,使用 flask+uwsgi+supervisor部署 ,查阅相关博客.调试.实操,已经 ...
- Nginx + tornado + supervisor部署
参考链接:supervisor + Tornado + Nginx 使用详解, 用tornado ,Supervisord ,nginx架网站, tornado官方文档 项目文档树: . ├── ch ...
- ubutu tornado python3.7.5 nginx supervisor 部署web api
环境: 1.Ubuntu 服务器 2.python3.7.5 安装 1.python3.7.5 安装的话还是比较简单,流程大致是./configure ->make && mak ...
- 阿里云服务器部署Tornado应用指南
本篇详细介绍tornado应用部署到阿里云服务器上的全过程. Tornado程序地址:github https://github.com/ddong8/ihasy.git 准备工作:阿里云服务器Cen ...
随机推荐
- div随着屏幕滚动而滚动
<script type="text/javascript"> $(document).ready(function () { var menuYloc = $(&qu ...
- Column常用的参数
#encoding: utf-8 from sqlalchemy import create_engine,Column,Integer,String,DateTime from sqlalchemy ...
- linux上传文件的命令——rz
下面来看一下有关上传下载的说明. 1.rz.sz命令的安装方法 第一种方法:安装系统时选包包含rz.sz命令的包组 第二种方法:安装系统后通过执行yum install lrzsz -y 或 yum ...
- luoguP1045 (Java大数)
题目链接:https://www.luogu.org/problemnew/show/P1045 题意:给定p(1000<p<3100000),求2^p-1的位数和最后500位(若不足高位 ...
- [转帖]Linux /tmp目录下执行脚本失败提示Permission denied
Linux /tmp目录下执行脚本失败提示Permission denied https://www.cnblogs.com/linyfeng/p/11087655.html 国产化的环境上 就有一个 ...
- linux shell脚本中使用expect(脚本打开新终端自动远程连接顺便输一点指令)(巨坑)
放弃吧 我找了六个小时都没找到可以用的方案(指标题括号里的内容) 给个曲线救国的方法: 现把expect脚本写成一个文件 在另一个shell脚本中调用
- mysql以及mysql bench安装教程
首先,我们需要去官网下载mysql(这里以下载) 1 2 3 4 5 下载好了自己好了之后,点击安装好的东西出现如下界面: 1.接受使用条款并点击next 2.点击custom,可以根据个人习惯进行安 ...
- Python_3day
循环 循环是一种控制语句块重复执行的结构 while 适用于广度遍历 for 开发中经常使用 while 循环 当一个条件保持真的时候while循环重复执行语句 while 循环一定要有结束条件, ...
- python基础之内置函数和匿名函数
内置函数 学习函数以后多了很多概念,例如函数的命名空间,函数的作用域,函数的调用等等,函数的作用就是为了实现某些功能而方便以后可以调用,内置函数就是这样的一些公共的函数,被称为内置函数. 我们就一 ...
- linux centos系统安装
1.下载镜像 https://www.centos.org/download/ DVD ISO 一般下载这个 erverything ISO 包含所有工具的版本 Minimal ISO最小启动版本 2 ...