拉取代码

  1. git clone https://github.com/w5teams/w5.git

安装依赖库

  1. # 默认国外源,国外服务器使用
  2. pip3 install -r requirements.txt
  3. # 使用国内源,国内服务器使用
  4. pip3 install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple

修改配置文件

执行 vi config.iniredis 没有密码无需填写

  1. [mysql]
  2. host = 127.0.0.1
  3. port = 3306
  4. database = w5_db
  5. user = root
  6. password = root
  7. [redis]
  8. host = 127.0.0.1
  9. port = 6379
  10. database = 0
  11. password =

运行项目

  1. [root@VM-8-9-centos w5]# python3 run.py
  2. ##@&$||;..!||||||||||;;||||||||%$@##@
  3. #@$%||||!` .;|||||;. `:!||||||$@@@
  4. @$%||||||||!` `!||||$@&
  5. &$||||||||||!. :|||||%$$
  6. $%||||||||||` `!||||||$$
  7. $%|||||||||;. :|||||$$
  8. $%||||||||!. .;|||$$
  9. &$||||||||; .!|:. `!%$$
  10. @$%||||||||;. .:|||!' .!&&
  11. #@$|||||||||||||||!` '%@@
  12. ##@$%|||||||||||!` :%@#@
  13. ###@&$||||||||!` !&###@
  14. #####@&&%||||:. `%&#####@
  15. ########&&&%: W5 SOAR '$&@#######@ v0.1
  16. =============================================
  17. * Web : https://w5.io
  18. * Github : https://github.com/w5hub/w5
  19. =============================================
  20. [2020-12-07 12:07:45 +0800] [4072781] [INFO] Starting gunicorn 20.0.4
  21. [2020-12-07 12:07:45 +0800] [4072781] [INFO] Listening at: http://0.0.0.0:8888 (4072781)
  22. [2020-12-07 12:07:45 +0800] [4072781] [INFO] Using worker: flask_sockets.Worker
  23. [2020-12-07 12:07:45 +0800] [4072798] [INFO] Booting worker with pid: 4072798
  24. [2020-12-07 12:07:45 +0800] [4072800] [INFO] Booting worker with pid: 4072800
  25. [2020-12-07 12:07:45 +0800] [4072802] [INFO] Booting worker with pid: 4072802

访问 W5 SOAR

  • 访问地址: ip:8888, (访问不了请检查服务器防火墙)
  • 账号密码: 账号:admin,密码:12345678 (登录后请及时修改密码)

login

生产环境部署

1.使用 Supervisor 守护进程

  1. # 生成 supervisor 配置文件
  2. echo_supervisord_conf3 > /etc/supervisord.conf

2.修改配置 vi /etc/supervisord.conf 最下面加入

  1. [program:w5]
  2. # 脚本执行命令
  3. command = python3 run.py
  4. # 项目目录路径,必须是绝对路径
  5. directory = /root/w5
  6. autostart = true
  7. autorestart = true
  8. redirect_stderr = true
  9. # 项目日记路径
  10. stdout_logfile=/opt/w5.log
  11. stdout_logfile_maxbytes = 20MB
  12. stdout_logfile_backups = 20

3.开启守护进程

  1. # 启动
  2. supervisord3 -c /etc/supervisord.conf
  3. # 如遇到以下错误:
  4. Error: Another program is already listening on a port that one of our HTTP servers is configured to use. Shut this program down first before starting supervisord.
  5. # 因为已经启动,所以直接更新配置即可
  6. supervisorctl3 -c /etc/supervisord.conf update

4.管理命令:

  1. # 启动项目
  2. supervisorctl3 start w5
  3. # 停止项目
  4. supervisorctl3 stop w5
  5. # 重启项目
  6. supervisorctl3 restart w5

Nginx 绑定域名

不配置域名访问,无需看此项

  1. server {
  2. listen 80;
  3. server_name demo.w5.io;
  4. location / {
  5. proxy_pass http://localhost:8888/;
  6. proxy_set_header Host $http_host;
  7. proxy_set_header X-real-ip $remote_addr;
  8. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  9. }
  10. # Websockt 设置项
  11. location /echo {
  12. proxy_pass http://localhost:8888/echo;
  13. proxy_http_version 1.1;
  14. proxy_set_header Upgrade $http_upgrade;
  15. proxy_set_header Connection "upgrade";
  16. }
  17. access_log off;
  18. }

重启 Nginx

  1. nginx -s reload

访问 W5 SOAR

浏览器访问:http://demo.w5.io