开源地址:https://github.com/gphper/grm
下载源码:git clone https://github.com/gphper/grm
找到目录下的web(vue) ,运行:

npm run build
#如果缺少vue-cli-service,运行 npm install vue-cli-service, 再编译
完成后生成dist文件目录,即项目前端界面。上传至服务器部署一个静态网页。



接下来编译go,先安装go依赖

brew install go
设置go代理,不然编译中会超时。

  go env -w GOPROXY=https://goproxy.cn
开始编译

go build -ldflags "-s -w" ./main.go  
生成的main 文件此时只能在mac 下运行,要生成centos下运行的二进制包 ,需要交叉编译。

GOOS=linux GOARCH=amd64 go build -o main main.go
此时查看main文件

 file main 
 #
 # main: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, Go BuildID=rX9FPSm0kXEsqDsubib_/UvDOPkAoRJZO5gJdgk-V/V5vW5AApFCGEeFxOPnMn/6IHCLuZkSQgOsHoYZ1eQ, with debug_info, not stripped
 #
上传至centos,

添加用户,登录使用

./main  user add 
然后输入您自定义的账户和密码
一次性运行,如果vue项目部署了,这个时候访问应该能看到redis 相关操作。

/www/download/main  srv run -H 127.0.0.1 -p 7890
#这里7890 是vue项目访问go默认的端口,如果你需要改成其他端口记得要修改vue项目中的端口
添加为服务自动运行

vim /etc/systemd/system/redis_client_web.service
文件内容:

[Unit]
Description=sentinel-dashboard
After=network.target
[Service]ExecStart=/www/download/main  srv run -H 127.0.0.1 -p 7890
Restart=always
[Install]
WantedBy=multi-user.target
wq保存退出,重载,修改文件权限,启动,开启

systemctl daemon-reload

chmod +x /etc/systemd/system/redis_client_web.service

systemctl start redis_client_web
 
systemctl enable redis_client_web

然后再nginx中代理部署

server
{
    #其他配置 grmapix 前缀也是vue 前端默认的自定义需要去修改vue前端的配置
    location /grmapix/ {
      proxy_pass http://127.0.0.1:7890;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "Upgrade";
    }
    #其他配置
}
ok,部署完成,重载nginx配置。。。