go打包 部署 优雅的把go项目部署到Linux服务器
linux-dash
A beautiful web dashboard for Linux
项目地址:https://gitcode.com/gh_mirrors/li/linux-dash
![](https://devpress.csdnimg.cn/6deffb34f7114cc1a2e1e686a67e0027.png)
·
注意问题
- go项目运行之后,修改.env文件不会立即生效,需要重启go服务才会生效
- go项目运行之后,修改config.ini配置文件会立即生效,无需重启go服务
重新部署项目
- 开发环境重新build项目(Mac环境的打包语法)
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build
- 查找指定端口的进程 博主的端口号9001
netstat -tunlp|grep 9001
- 结束之前的进程,开启新进程启动go服务
- 4543是要结束的进程
- singo是二进制文件名
- 使用&&同时执行2条命令,避免服务中断
kill -9 4543 && nohup ./singo > nohup.log 2>&1 &
附录Windows平台的打包语法
windows
set CGO_ENABLED=0 //禁用CGO
set GOOS=linux //目标平台为linux
set GOARCH=amd64 //目标处理器架构是amd64
go build -o name //编译可执行文件到当前目录 (-o:自定义文件名)
Mac
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build
![]( https://profile-avatar.csdnimg.cn/default.jpg)
![](https://devpress.csdnimg.cn/7174e1ca86c447029bb12f9ec0bd281c.png)
![](https://devpress.csdnimg.cn/096f7827187446559bd7b6030eb5db38.png)
![](https://devpress.csdnimg.cn/6deffb34f7114cc1a2e1e686a67e0027.png)
A beautiful web dashboard for Linux
最近提交(Master分支:5 个月前 )
186a802e
added ecosystem file for PM2 4 年前
5def40a3
Add host customization support for the NodeJS version 4 年前
更多推荐
所有评论(0)