1
314x OP supervisor的conf配置如下:
[unix_http_server] file=/tmp/supervisor.sock [inet_http_server] port=9001 username = admin password = 123456 [rpcinterface:supervisor] supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface [supervisorctl] serverurl=unix:///tmp/supervisor.sock [supervisord] logfile=/var/log/supervisord.log logfile_maxbytes=50MB logfile_backups=10 loglevel=info pidfile=/var/run/supervisord.pid nodaemon=false minfds=1024 minprocs=200 [program:f2e] command = python /srv/www/website/run.py 80%(process_num)02d process_name=%(program_name)s_80%(process_num)02d ; process_name expr (default %(program_name)s) numprocs=4 numprocs_start=1 autostart=true autorestart=true startsecs=5 startretries=3 stopsignal=QUIT redirect_stderr=true stdout_logfile=/var/log/flask-access.log |
2
jerry 2013-12-28 12:10:53 +08:00
Address already in use 的意思是端口被占用了
|
3
314x OP @jerry 是的,但是我用sudo lsof -i:8001-8004,发现这四个端口都是空的,根本没有占用,用9001的管理端口看到状态全部是fatal
|
4
314x OP 刚刚kill掉nginx占用的端口,重启supervisor后发现有一个进程可以起来,其他三个还是fatal,本地访问8080端口可以看到程序,这是怎么回事?
|
5
lerry 2013-12-28 12:22:47 +08:00 via Android
tornado怎么写的,端口参数传进去了吗
|
6
314x OP @lerry 用的8080端口
def main(): tornado.options.parse_command_line() http_server = tornado.httpserver.HTTPServer(Application()) http_server.listen(options.port) tornado.ioloop.IOLoop.instance().start() |
7
muxi 2013-12-28 12:45:11 +08:00 1
|
8
lerry 2013-12-28 12:47:09 +08:00 2
怎么是8080?不应该是supervisor传过去的8001~8004?
只有一个端口参数的话,你用http_server.listen(sys.argc[1])就可以了 parse_command_line()我没用过,大概看了一下,应该是这么写的吧 command = python /srv/www/website/run.py --port=80%(process_num)02d |
9
lerry 2013-12-28 12:48:19 +08:00
手误,上面应该是sys.argv[1]
|
10
314x OP @muxi @lerry
谢谢两位,确实改成command = python /srv/www/website/run.py --port=80%(process_num)02d后,supervisor四个进程都起来了,但是启动nginx后,访问127.0.0.1:8080后,出现500: Internal Server Error。之前有一个进程起来的时候,至少可以访问localhost,我是用ngxin监听8080端口,反向代理tornado 8001-8004四个端口的,配置如下: user nginx; worker_processes 1; error_log /var/log/nginx/error.log; pid /var/run/nginx.pid; events { worker_connections 1024; use epoll; } http { # Enumerate all the Tornado servers here upstream frontends { server 127.0.0.1:8001; server 127.0.0.1:8002; server 127.0.0.1:8003; server 127.0.0.1:8004; } include /etc/nginx/mime.types; default_type application/octet-stream; access_log /var/log/nginx/access.log; keepalive_timeout 65; proxy_read_timeout 200; sendfile on; tcp_nopush on; tcp_nodelay on; gzip on; gzip_min_length 1000; gzip_proxied any; gzip_types text/plain text/css text/xml application/x-javascript application/xml application/atom+xml text/javascript; # Only retry if there was a communication error, not a timeout # on the Tornado server (to avoid propagating "queries of death" # to all frontends) proxy_next_upstream error; server { listen 8080; server_name localhost; # Allow file uploads client_max_body_size 50M; location static/ { root /srv/www/website/; if ($query_string) { expires max; } } location = /favicon.ico { rewrite (.*) /static/favicon.ico; } location = /robots.txt { rewrite (.*) /static/robots.txt; } location / { proxy_pass_header Server; proxy_set_header Host $http_host; proxy_redirect off; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Scheme $scheme; proxy_pass http://frontends; } } } |