perf(package static file): 去除打包静态文件到二进制文件的第三方工具
This commit is contained in:
@@ -33,11 +33,8 @@ OpenVPN的管理端口详细介绍文章,请参考:https://openvpn.net/commu
|
||||
```bash
|
||||
git clone
|
||||
cd openvpn-manager
|
||||
go get github.com/rakyll/statik
|
||||
go install github.com/rakyll/statik
|
||||
statik -src=$PWD/public
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o openvpn-manager main.go
|
||||
nohup ./openvpn-manager -host openvpn服务端主机IP地址 -port openvpn管理端口 -admin-passwd OpenVPN Manager管理员admin的密码 -psw-file /etc/openvpn/server/psw-file >> /var/log/openvpn-manager.log 2>&1 &
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o target/openvpn-manager main.go
|
||||
nohup ./target/openvpn-manager -host openvpn服务端主机IP地址 -port openvpn管理端口 -admin-passwd OpenVPN Manager管理员admin的密码 -psw-file /etc/openvpn/server/psw-file > /var/log/openvpn-manager.log 2>&1 &
|
||||
```
|
||||
|
||||
## 3、docker方式部署
|
||||
|
||||
11
main.go
11
main.go
@@ -2,13 +2,11 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
_ "curiouser.com/openvpn-manager/statik"
|
||||
"encoding/csv"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/rakyll/statik/fs"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net"
|
||||
@@ -93,19 +91,14 @@ func main() {
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
statikFS, err := fs.New()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
//根路由设置首页跳转到'/public'加载'index.html'
|
||||
router.GET("/", func(context *gin.Context) {
|
||||
context.Request.URL.Path = "/public"
|
||||
router.HandleContext(context)
|
||||
})
|
||||
|
||||
authorizedRoute.StaticFS("/public", statikFS)
|
||||
//authorizedRoute.StaticFS("/public",http.Dir("./public"))
|
||||
// authorizedRoute.StaticFS("/public", statikFS)
|
||||
authorizedRoute.StaticFS("/public",http.Dir("./public"))
|
||||
authorizedRoute.StaticFile("/favicon.ico", "./public/favicon.ico")
|
||||
|
||||
authorizedRoute.GET("/getOnlineClients", func(context *gin.Context) {
|
||||
|
||||
Reference in New Issue
Block a user