ICode9

精准搜索请尝试: 精确搜索
首页 > 数据库> 文章详细

SQL审计平台之Archery安装之Gunicorn+Nginx方式启动

2021-07-23 21:34:01  阅读:256  来源: 互联网

标签:Archery Gunicorn Nginx 0.0 supervisord nginx proxy true LISTEN


一、nginx相关配置

yum安装

yum install nginx

修改配置代理

vim /etc/nginx/nginx.conf #修改server配置
server{
        listen 9123; # nginx监听的端口
        server_name archery;
        client_max_body_size 20M; # 处理Request Entity Too Large
        proxy_read_timeout 600s;  # 超时时间与Gunicorn超时时间设置一致,主要用于在线查询

        location / {
          proxy_pass http://127.0.0.1:8000;#程序绑定的地址
          proxy_set_header Host $host:9123; # 解决重定向404的问题,和listen端口保持一致,如果是docker则和宿主机映射端口保持一致
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header X-Forwarded-Proto $scheme;
        }

        location /static {
          alias /application/Archery-1.8.0/static; # 此处指向settings.py配置项STATIC_ROOT目录的绝对路径,用于nginx收集静态资源
        }

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
}

启动

nginx -t
systemctl start nginx.service
systemctl status nginx.service

二、启动MySQL

此处为settings.py文件里的数据库

ps -ef|grep mysql

三、启动inception,goinception,redis

nohup /usr/local/redis/bin/redis-server  /usr/local/redis/etc/redis.conf &
nohup ./Inception --defaults-file=inc.cnf &
nohup ./goInception -config=conf.toml &

四、修改supervisord配置

supervisord是一个进程管理工具,通过它来管理gunicorn,它可以很方便的监听、启动、停止、重启一个或多个进程。用Supervisor管理的进程,当一个进程意外被杀死,supervisort监听到进程死后,会自动将它重新拉起,很方便的做到进程自动恢复的功能,不再需要自己写shell脚本来控制。gunicorn是一个高性能的Python WSGI UNIX HTTP Server,通过它来启动我们的python程序。

vim supervisord.conf 

  1 [unix_http_server]                                                                                                                         
  2 file=supervisor.sock
  3 
  4 [supervisord]
  5 logfile=logs/supervisord.log
  6 nodaemon=false
  7 
  8 [supervisorctl]
  9 serverurl=unix://supervisor.sock
 10 
 11 [rpcinterface:supervisor]
 12 supervisor.rpcinterface_factory=supervisor.rpcinterface:make_main_rpcinterface
 13 
 14 [program:archery]
 15 command=gunicorn -w 4 -k uvicorn.workers.UvicornWorker -b 127.0.0.1:8000 --timeout 600 archery.asgi:application
 16 autorestart=true
 17 stopasgroup=true
 18 killasgroup=true
 19 redirect_stderr=true
 20 
 21 [program:qcluster]
 22 command=python manage.py qcluster
 23 autorestart=true
 24 stopasgroup=true
 25 killasgroup=true
 26 redirect_stderr=true

运行startup脚本启动

cat startup.sh 
#!/bin/bash

# 收集所有的静态文件到STATIC_ROOT
python3 manage.py collectstatic -v0 --noinput

# 启动服务
supervisord -c supervisord.conf
bash startup.sh

查看端口

netstat -tnl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 127.0.0.1:6379          0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:8000          0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:9123            0.0.0.0:*               LISTEN     
tcp6       0      0 :::6669                 :::*                    LISTEN     
tcp6       0      0 :::22                   :::*                    LISTEN     
tcp6       0      0 :::3356                 :::*                    LISTEN     
tcp6       0      0 :::3357                 :::*                    LISTEN     
tcp6       0      0 :::4000                 :::*                    LISTEN

五、登陆

访问10。0.0.51:9123,登陆
首页

 生产环境使用该方式进行配置。

标签:Archery,Gunicorn,Nginx,0.0,supervisord,nginx,proxy,true,LISTEN
来源: https://www.cnblogs.com/yang417/p/15053868.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有