# Go Runner 安装使用说明

# 下载

您可以在此链接 下载 (opens new window) 根据您的操作系统下载指定平台发行包,下载完成解压到任意文件夹。你看到的目录结构如下

image-20210712111052939

# 配置

配置项目 etc/config.yaml

# 配置文件
Host: "127.0.0.1" # 运行addr
Port: "8080"      # 运行端口

# webhook 自动化部署回调域名,根域名,如www.gn.com/www.ol.com
Domain: "http://go.runner.io"

# mysql (此处配置暂时不用理会)
MysqlDNS: mysql://root:123456@tcp(127.0.0.1:3306)/pave?charset=utf8mb4&parseTime=True&loc=Local
TimeZone: Asia/Shanghai

# 本地redis连接配置
RedisDNS: 61c07e1ae08d08a2@127.0.0.1:6379
# 默认redis使用库
DefaultDb: 1
# redis队列使用库
QueueDb: 12
# 消费者work数量 
WorkNumber: 1

# Nginx 配置

upstream runner {
    server 0.0.0.0:8080 weight=1;
}

server {
    listen       80;
    server_name  go.runner.io; # 域名设置
    access_log   /usr/local/var/log/nginx/runner.log; # 日志目录
    error_log    /usr/local/var/log/nginx/runner.error.log; # 日志目录

    index index.html index.htm;

    add_header Access-Control-Allow-Origin *;
    add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS, PUT, DELETE, PATCH';
    add_header Access-Control-Allow-Headers 'DNT,Keep-Alive,User-Agent,Cache-Control,Content-Type,Authorization,Access-Token';
    # cors
    if ($request_method = 'OPTIONS') {
        return 204;
    }

    # api
    location / {
        client_max_body_size       50m;
        client_body_buffer_size    128k;
        proxy_connect_timeout      300;
        proxy_send_timeout         300;
        proxy_read_timeout         300;
        proxy_buffer_size          4k;
        proxy_buffers              4 32k;
        proxy_busy_buffers_size    64k;
        proxy_temp_file_write_size 64k;

        # 将客户端的 Host 和 IP 信息一并转发到对应节点
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header REMOTE-HOST $remote_addr;
        proxy_set_header HTTP-VIA $http_via;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        # 转发Cookie,设置 SameSite
        # proxy_cookie_path / "/; secure; HttpOnly; SameSite=strict";
        proxy_cookie_path / "/; HttpOnly; SameSite=Lax";

        # 执行代理访问真实服务器
        proxy_pass http://runner;
    }
    
    # websocket
    location /ws {
        proxy_set_header Upgrade "websocket";
        proxy_set_header Connection "upgrade";
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
        proxy_http_version 1.1;

        # 转发到多个 ws server
        proxy_pass http://runner;
    }
}

# 运行项目

运行项目前请保证 data 目录和 runtime 目录的可写权限

windows 用户打开cmd 运行 .\awesome-runner.exe

mac、linux 运行 ./awesome-runner ,项目运行成功如下:

image-20210712112039553

打开浏览器访问 http://go.runner.io/web web控制台

# 项目部署脚本

需要明确部署脚本文件名为 .runner-ci.yml,它是存在于您的实际项目根目录下,随 仓库提交更新下载,用于约束和申明部署时执行的脚本的配置文件。配置文件格式说明如下:

# 工作目录
webpath: /Users/zrone/Developments/dtest/runnnn
# 部署分支,至少一个,可以配置多个,用于自动化部署触发部署
only:
  - master
  - dev
  - test
# 环境变量,用于脚本执行时申明环境变量,仅当前session有效,不会污染全局,可配置多个
environment:
  workdir: /home/wwwroot/deploy
  a: b
  c: d
# pull前运行脚本
prepare:
  - nginx -s stop
# pull 完成运行脚本
script:
  - cd ${webpath} && pwd
# 发布运行脚本
release:
  - nginx 
  - netstae -tunlp | grep 8080