一、设置环境
如果是linux
set GOARCH=amd64
go env -w GOARCH=amd64
set GOOS=linux
go env -w GOOS=linuxCopy还原win环境
go env -w GOARCH=amd64
go env -w GOOS=windowsCopy二、打包
go buildCopy三、部署
ps aux|grep main
chmod 773 main
nohup ./main ./conf/prod_config.ini > ./log &Copy通过名称去杀死进程
ps -aux|grep Lc_Go| grep -v grep | awk '{print $2}'|xargs kill -9Copy设置程序的权限
chmod 773 /www/web/LC_API/Lc_GoCopy运行程序
nohup /www/web/LC_API/Lc_Go /www/web/LC_API/conf/prod_config.ini > ./log 2>&1 &Copy完整代码
#!/bin/bash
ps -aux|grep Lc_Go| grep -v grep | awk '{print $2}'|xargs kill -9
chmod 773 /www/web/LC_API/Lc_Go
nohup /www/web/LC_API/Lc_Go /www/web/LC_API/conf/prod_config.ini > ./log 2>&1 &