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在查阅 ...
随机推荐
- 使用ASP.NET Web Api构建基于REST风格的服务实战系列教程【三】——Web Api入门
系列导航地址http://www.cnblogs.com/fzrain/p/3490137.html 前言 经过前2节的介绍,我们已经把数据访问层搭建好了,从本章开始就是Web Api部分了.在正式开 ...
- Hash Table in C
http://www.sparknotes.com/cs/searching/hashtables/section3.rhtml http://en.literateprograms.org/Spec ...
- ubuntu qq
系统:Ubuntu 14.04 64位 1.下载qq国际版(直接网络搜索就可以) 2.解压并安装: # cp wine-qqintl.zip /usr/local/ # pwd/usr/local/ ...
- iOS 生命周期
应用生命周期 App启动:当App启动时,首先由not running状态切换到inactive状态,此时调用application:didFinishLaunchingWithOptions: ...
- android自定义控件(5)-实现ViewPager效果
对于系统的ViewGroup我们已经是十分熟悉了,最常用的LinearLayout和RelativeLayout几乎是天天要打交道,下面我们就来看看,如何一步一步将其实现: 一.首先当然也是最通常的新 ...
- [asp.net core]project.json(1)
摘要 前面介绍了使用vs2015新建asp.net core web的内容,这篇文章学习下project.json文件的内容. project.json 原文:https://docs.microso ...
- underflow 、overflow 下溢和上溢
在strtoull函数返回值中,就提到上溢和下溢的问题,现在把这俩个概念拿出来涨涨见识! 上溢 Overflow 是当一个超长的数据进入到缓冲区时,超出部分被写入上级缓冲区,上级缓冲区存放的可能是数 ...
- 妈咪,我找到了! -- 15个实用的Linux find命令示例
妈咪,我找到了! -- 15个实用的Linux find命令示例 英文原文:Mommy, I found it! — 15 Practical Linux Find Command Examples ...
- 导入excel错误:外部表不是预期的格式 解决方案
环境:win7+iis7+Office2007 在asp.net网站中导出Excel文件后,再把文件导入到数据库中. 读取Excel文件时,打开连接出错. 错误为:外部表不是预期的格式 解决:检查了一 ...
- word中那些重要但是被人忽略的快捷键和长word文档的跳转
重复上一次操作: F4, 这个太重要了,比如你在做一次很复杂的操作, 下一次又要这样操作时就很有用! 如设置 文字的 段落背景/ 底纹颜色!时要多次设置这个时就 非常有用! 段落缩进:ctrl+M : ...