看了比较多的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 的一点记录的更多相关文章

  1. ubuntu下python+tornado+supervisor+nginx部署

    由于项目需要,老师让我写一个小web系统,之前都是用java写web,想到自己最近学机器学习要用python,所以用python来写一下,此外,因为想用点新东西,也介于程序比较小,所以考虑用mongo ...

  2. tornado + supervisor + nginx + linux 亲身体验

    先说说思路 一.安装这些东西,tornado, supervisor( sudo pip install supervisor  在linux 系统上), 安装 nginx  (sudo apt-ge ...

  3. 关于nginx的一点记录

    (1) 安装nginx官网下载:http://nginx.org下载适合Windows的安装包,是一个压缩包,直接解压就可以了. (2) 启动nginx有三种方式启动:a. 双击nginx.exe图标 ...

  4. 学习nginx的一点记录

    一.nginx定义 Nginx是一款轻量级的.高性能的,具备HTTP.反向代理.负载均衡的web服务器,同时还提供IMAP/POP3/SMTP服务,其特点是占用内存少,并发能力强. 二.nginx基本 ...

  5. Nginx + tornado + supervisor部署

    参考链接:supervisor + Tornado + Nginx 使用详解, 用tornado ,Supervisord ,nginx架网站, tornado官方文档 项目文档树: . ├── ch ...

  6. centos7 使用nginx + tornado + supervisor搭建服务

    如何在Linux下部署一个简单的基于Nginx+Tornado+Supervisor的Python web服务. Tornado:官方介绍,是使用Python编写出来的一个极轻量级.高可伸缩性和非阻塞 ...

  7. 关于Java8:StreamAPI的一点记录

    关于 Stream ,Functional Interface 的一点记录 stream对于集合操作的便捷度提升: import java.util.ArrayList; import java.ut ...

  8. 对Integer类中的私有IntegerCache缓存类的一点记录

    对Integer类中的私有IntegerCache缓存类的一点记录 // Integer类有内部缓存,存贮着-128 到 127. // 所以,每个使用这些数字的变量都指向同一个缓存数据 // 因此可 ...

  9. 从symbol link和hard link 到 unlink函数的一点记录

    之前一直对Linux的文件类型中的 “l” 类型的了解不是很深入,最近经过“圣经”指点,略知一二,在此先记录一下,以便以后查阅,之后会对文件和目录.文件I/O这部分再扩充. 首先需明确,Unix在查阅 ...

随机推荐

  1. 第3章 jQuery的DOM操作

    一.  DOM 分为DOM核心,HTML-DOM和CSS-DOM 1.DOM核心 不专属与javascript. 获取对象:document.getElementsByTagName('div') 获 ...

  2. JabRef 文献管理软件

    JabRef 文献管理软件简明教程 大多只有使用LaTeX撰写科技论文的研究人员才能完全领略到JabRef的妙不可言,但随着对Word写作平台上BibTeX4Word插件的开发和便利应用,使用Word ...

  3. Python之迭代器和生成器

    Python 迭代器和生成器 迭代器 Python中的迭代器为类序列对象(sequence-like objects)提供了一个类序列的接口,迭代器不仅可以对序列对象(string.list.tupl ...

  4. 集合 ArrayList

    /* * 功能:演示java集合的用法:ArrayList */ package com.jihe; //先引入一个包 import java.util.ArrayList; public class ...

  5. python基础教程1

    python作为一种编程语言,诞生于1990年左右,算是一门比较年轻的语言(也算是90后吧),它是面向对象的,但不同于JAVA\C#那么严格要求一切皆对象,更接近于C++,是面向过程和面向对象的结合: ...

  6. Linux运维初级教程(一)Shell脚本

    序,掌握shell脚本是linux运维工程师的最基础技能. 一.脚本语言 与高级语言不通,脚本语言运行时需要调用相应的解释器来翻译脚本中的内容. 常见的脚本语言有Shell脚本.Python脚本.ph ...

  7. EF-联合查询-结果集-Group by-统计数目

    EF框架用着痛并且快乐着··· 毕竟用习惯了SQL语句直接硬查的··· SELECT C0.ID,C_C.Name,C_C.C_COUNT FROM article_type C0 INNER JOI ...

  8. SQLite初试...

    string dataPath = "../../UserData.dbx"; //System.IO.Directory.GetCurrentDirectory() + &quo ...

  9. 收到的电邮附件为Winmail.dat?

    以下信息来源于微软帮助中心:您收到电子邮件,其中包含一个 winmail.dat 的附件.电子邮件被人使用的 Microsoft Outlook 发送给您.该邮件的格式是丰富文本格式 (RTF). 原 ...

  10. iOS9 Universal Link实现

    先来贴几个比较全面的帖子,看完就差不多了. 1   iOS 9 通用链接(Universal Links) 帖子注意项非常重要,仔细阅读. 自己补充几点: 1 服务器上配置的json文件apple-a ...