看了比较多的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. debian vmwareTools安装总结

    1.安装GCC编译器和make:      因为安装VMwareTools需要编译和make所以要先安装它们.安装其实很简单,命令如下: apt-get install gcc make 其实你也可以 ...

  2. Effective Objective-C 2.0 — 第一条:了解Objective-C语言的起源

    第一条: 了解Objective-C语言的起源 由Smalltalk演化而来,消息型语言的鼻祖(messaging structure)而非 (function calling)函数调用 //Mess ...

  3. Orchard源码分析(2):Orchard.Web.MvcApplication类(Global)

    概述 分析一个的ASP.NET项目源码,首先可以浏览其项目结构,大致一窥项目其全貌,了解项目之间的依赖关系.其次可以浏览Web.config和Global.asax文件,找到应用程序的入口点. 本 文 ...

  4. firefox 提示 setTimeout():useless setTimeout call (missing quotes around argument?) 错误

    原来代码: setTimeout(window.parent.refreshNode(id),500);// 500毫秒后,调用父窗口的refreshNode()方法 refreshNode()方法总 ...

  5. Task异常处理

    http://www.cnblogs.com/xray2005/archive/2011/08/24/2151459.html

  6. C# Redis消息队列例子

    class Program { //版本2:使用Redis的客户端管理器(对象池) public static IRedisClientsManager redisClientManager = ne ...

  7. vim黏贴代码格式混乱的解决方法

    from:http://blog.csdn.net/commshare/article/details/6215088 感谢牛人的文章.解决了我在vim使用中,很头疼的问题. 在vim新建文件的时候, ...

  8. [译]A Beginner’s Guide to npm — the Node Package Manager

    原文: http://www.sitepoint.com/beginners-guide-node-package-manager/ Installing Node.js 验证你的安装是否成功. $ ...

  9. git/gitLab

    gitlab安装:http://www.360doc.com/content/15/0603/14/21631240_475362133.shtml http://www.cnblogs.com/wi ...

  10. 3_mysql 主从复制

    mysql 主从复制 网易数据库 石勇 提纲 什么是主从复制 主从复制的原理 主从复制的用途 主从复制的搭建 主从复制的问题 什么是主从复制 数据拷贝 准实时 源-主节点:目的-从节点 主从复制的原理 ...