Nginx(单进程): 反向代理, 负载均衡。图解
将配置文件 nginx.conf 的 user xx 配置好 xx用户
检查语法
$ sudo service nginx configtest
重新加载配置文件并重启nginx
$ sudo service nginx reload
重启nginx
$ sudo service nginx restart
启动
$ sudo service nginx start
停止
$ sudo service nginx stop
更多详细nginx,supervisor,celery资料:https://www.cnblogs.com/tangpg/p/8962773.html
Supervisor: 进程管理工具
启动supervisor
supervisord -c supervisord.conf 启动客户端
supervisorctl -c supervisord.conf 客户端内操作进程
> status # 查看程序状态
> stop tornadoes:tornado-8000 # 关闭 程序
> start tornadoes:tornado-8000 # 启动 程序
> restart tornadoes:tornado-8000 # 重启 程序
> reread # 读取有更新(增加)的配置文件,不会启动新添加的程序
> update # 重启配置文件修改过的程序 控制台操作进程
$ supervisorctl status
$ supervisorctl stop tornadoes:tornado-8000
$ supervisorctl start tornadoes:tornado-8000
$ supervisorctl restart tornadoes:tornado-8000
$ supervisorctl reread
$ supervisorctl update 操作步骤
(friend_server_test1) rock1@rock1:~/work/tornado_test/friends_server$ supervisorctl -c supervisord.conf
tornadoes:tornado-8000 RUNNING pid 2534, uptime 0:00:19
tornadoes:tornado-8001 RUNNING pid 2535, uptime 0:00:19
supervisor> status
tornadoes:tornado-8000 RUNNING pid 2534, uptime 0:02:39
tornadoes:tornado-8001 RUNNING pid 2535, uptime 0:02:39
supervisor> stop tornadoes:tornado-8000
tornadoes:tornado-8000: stopped
supervisor> status
tornadoes:tornado-8000 STOPPED Jul 24 04:28 AM
tornadoes:tornado-8001 RUNNING pid 2535, uptime 0:03:04
supervisor> start tornadoes:tornado-8000
tornadoes:tornado-8000: started
supervisor> status
tornadoes:tornado-8000 RUNNING pid 2553, uptime 0:00:07
tornadoes:tornado-8001 RUNNING pid 2535, uptime 0:03:47
supervisor> restart tornadoes:tornado-8000
tornadoes:tornado-8000: stopped
tornadoes:tornado-8000: started
supervisor> reread
tornadoes: changed
supervisor> update
tornadoes: stopped
tornadoes: updated process group
supervisor>
在项目根目录创建supervisor.conf加入以下内容
[group:tornadoes] # 进程组
programs=tornado-8000,tornado-9001 # 放n个进程 [program:tornado-8000] # 如果存在
command=python server.py -runserver -port=8000 # 执行
directory=/home/pyvip/oasystem # 工作目录(此文件(xx.conf)目录)
use=ubuntu
autorestart=true
redirect_stderr=true
stdout_logfile=/home/pyvip/log/oasystem.log # 日志 tail -f oasystem.log动态查看
loglevel=info [program:tornado-9001]
command=python server.py -runserver -port=9001
directory=/home/pyvip/oasystem
use=pyvip
autorestart=true
redirect_stderr=true
stdout_logfile=/home/pyvip/log/oasystem.log
loglevel=info [supervisord] [supervisorctl]
serverurl=http://192.168.10.128:9999 # 内网ip时192.168.1.102能直接访问9999端口,反而设置的用不了。设置有啥作用?
username=superadmin
password=222 [inet_http_server]
port=:9999
username=superadmin
password=222 [rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface