tornado + supervisor + nginx 的一点记录
看了比较多的blog基本都是这个架构:
supervisor ------------ app1
|-------app2
|-------....
|-------appn
|-------nginx
|-------redis
统一都交给supervisor来管理。总觉得哪里不对:
1) nginx作为supervisor的子进程,会有问题,它貌似会不断的去执行启动(导致大量的错误日志:端口已经被占用)
2) nginx 和 redis 的启动与配置与app之间应该是没有耦合关系的,和supervisor也是没有耦合关系的。
===================
自己整理微调如下:
-----------------------
supervisor -----|------- app1
|------- appn
nginx ---------|---------proxy1
|---------proxy2
redis
这个部署架构意味着要做多个脚本,并加入到开机启动项里面去。supervisor/nginx/redis各需要一个。
nginx 脚本如下:
#!/bin/bash
# nginx Startup script for the Nginx HTTP Server
# it is v.0.0.2 version.
# chkconfig: - 85 15
# description: Nginx is a high-performance web and proxy server.
# It has a lot of features, but it's not for everyone.
# processname: nginx
# pidfile: /var/run/nginx.pid
# config: /usr/local/nginx/conf/nginx.conf
nginxd=/usr/local/nginx/sbin/nginx
nginx_config=/usr/local/nginx/conf/nginx.conf
nginx_pid=/var/run/nginx.pid
RETVAL=0
prog="nginx"
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
[ -x $nginxd ] || exit 0
# Start nginx daemons functions.
start() {
if [ -e $nginx_pid ];then
echo "nginx already running...."
exit 1
fi
echo -n $"Starting $prog: "
daemon $nginxd -c ${nginx_config}
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
return $RETVAL
}
# Stop nginx daemons functions.
stop() {
echo -n $"Stopping $prog: "
killproc $nginxd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /var/run/nginx.pid
}
# reload nginx service functions.
reload() {
echo -n $"Reloading $prog: "
#kill -HUP `cat ${nginx_pid}`
killproc $nginxd -HUP
RETVAL=$?
echo
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
stop
start
;;
status)
status $prog
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|reload|status|help}"
exit 1
esac
exit $RETVAL
supervisor 由于根具体的应用对应,因此脚本也应该根据具体应用命名,比如有一个应用叫做 didibus
#!/bin/sh
#
# /etc/rc.d/init.d/supervisord
#
# Supervisor is a client/server system that
# allows its users to monitor and control a
# number of processes on UNIX-like operating
# systems.
#
# chkconfig: - 64 36
# description: Supervisor Server
# processname: supervisord # Source init functions
. /etc/rc.d/init.d/functions prog="didibus" prefix="/usr"
exec_prefix="${prefix}"
prog_bin="${exec_prefix}/bin/supervisord"
PIDFILE="/var/run/$prog.pid" config_file="/path/to/didibus/supervisord.conf" start()
{
echo -n $"Starting $prog: "
daemon $prog_bin -c $config_file --pidfile $PIDFILE
[ -f $PIDFILE ] && success $"$prog startup" || failure $"$prog startup"
echo
} stop()
{
echo -n $"Shutting down $prog: "
echo
for i in {1..4}
do supervisorctl -c $config_file stop cool_talk_server$i
done
[ -f $PIDFILE ] && killproc $prog || success $"$prog shutdown"
echo
} restart_childs()
{
echo -n $"restarting childs of $prog: "
echo
for i in {1..4}
do supervisorctl -c $config_file restart didibus$i
done
} case "$1" in start)
start
;; stop)
stop
;; status)
status $prog
;; restart)
stop
start
;; restart_childs)
restart_childs
;; *)
echo "Usage: $0 {start|stop|restart|restart_childs|status}"
;; esac
然后将脚本放在/etc/init.d/目录下,并加入启动项,对于各种类型的linux,命令有所差异,centos如下:
chkconfig --add service_script
chkconfig service_script on
tornado + supervisor + nginx 的一点记录的更多相关文章
- ubuntu下python+tornado+supervisor+nginx部署
由于项目需要,老师让我写一个小web系统,之前都是用java写web,想到自己最近学机器学习要用python,所以用python来写一下,此外,因为想用点新东西,也介于程序比较小,所以考虑用mongo ...
- tornado + supervisor + nginx + linux 亲身体验
先说说思路 一.安装这些东西,tornado, supervisor( sudo pip install supervisor 在linux 系统上), 安装 nginx (sudo apt-ge ...
- 关于nginx的一点记录
(1) 安装nginx官网下载:http://nginx.org下载适合Windows的安装包,是一个压缩包,直接解压就可以了. (2) 启动nginx有三种方式启动:a. 双击nginx.exe图标 ...
- 学习nginx的一点记录
一.nginx定义 Nginx是一款轻量级的.高性能的,具备HTTP.反向代理.负载均衡的web服务器,同时还提供IMAP/POP3/SMTP服务,其特点是占用内存少,并发能力强. 二.nginx基本 ...
- Nginx + tornado + supervisor部署
参考链接:supervisor + Tornado + Nginx 使用详解, 用tornado ,Supervisord ,nginx架网站, tornado官方文档 项目文档树: . ├── ch ...
- centos7 使用nginx + tornado + supervisor搭建服务
如何在Linux下部署一个简单的基于Nginx+Tornado+Supervisor的Python web服务. Tornado:官方介绍,是使用Python编写出来的一个极轻量级.高可伸缩性和非阻塞 ...
- 关于Java8:StreamAPI的一点记录
关于 Stream ,Functional Interface 的一点记录 stream对于集合操作的便捷度提升: import java.util.ArrayList; import java.ut ...
- 对Integer类中的私有IntegerCache缓存类的一点记录
对Integer类中的私有IntegerCache缓存类的一点记录 // Integer类有内部缓存,存贮着-128 到 127. // 所以,每个使用这些数字的变量都指向同一个缓存数据 // 因此可 ...
- 从symbol link和hard link 到 unlink函数的一点记录
之前一直对Linux的文件类型中的 “l” 类型的了解不是很深入,最近经过“圣经”指点,略知一二,在此先记录一下,以便以后查阅,之后会对文件和目录.文件I/O这部分再扩充. 首先需明确,Unix在查阅 ...
随机推荐
- C++ 泛型基础
C++ 泛型基础 泛型的基本思想:泛型编程(Generic Programming)是一种语言机制,通过它可以实现一个标准的容器库.像类一样,泛型也是一种抽象数据类型,但是泛型不属于面向对象,它是面向 ...
- acm 选夫婿
选夫婿1 Time Limit: 1000MS Memory limit: 32768K 题目描述 倾国倾城的大家闺秀潘小姐要选夫婿啦!武林中各门各派,武林外各大户人家,闻讯纷纷前来,强势围观 ...
- Robot Framework--01 创建简单工程示例
1.新建Project: 填写name,选择Type为Dirctory,路径根据自己需要选择,建议最好不要在中文路径下,以免发生问题:
- linq按条件sum
var result = fruit.GroupBy(i => i.date) .Select(i => new { date = i.Key, no_of_apple = i.Where ...
- 为什么要做url encode
因为 url 对字符有限制,比如把一个邮箱放入 url,就需要使用 urlencode 函数,因为 url 中不能包含 @ 字符.
- SHIFT后门拿服务器之方法总结
提权工具如下:cmd.exe Churrasco.exe nc.exe 提权前提:Wscript组件成功开启 如果Wscript组件被关闭,则使用以下方法开启: 源代码: <object run ...
- 在Razor中如何引入命名空间?("import namespace in razor view") 【转】
原文链接 找了半天,原来如此: 在aspx中: <%@ Import Namespace = "Martian.Areas.SFC.Models" %><%@ I ...
- JSP指令
一.JSP指令简介 JSP指令(directive)是为JSP引擎而设计的,它们并不直接产生任何可见输出,而只是告诉引擎如何处理JSP页面中的其余部分. 在JSP 2.0规范中共定义了三个指令: pa ...
- mysql分表的3种方法(转)
一,先说一下为什么要分表 当一张的数据达到几百万时,你查询一次所花的时间会变多,如果有联合查询的话,我想有可能会死在那儿了.分表的目的就在于此,减小数据库的负担,缩短查询时间. 根据个人经验,mysq ...
- 3步完成chrome切换搜索引擎
1.打开chrome://settings/,找到搜索 2.点击“管理搜索引擎”,出现弹窗. 增加搜索引擎,三个文本框分别输入:名称.快捷键.地址 3.在新的选项卡中,输入快捷键(如:github), ...