From 206cfebb9a6a35a782e40571a133a9af14e12772 Mon Sep 17 00:00:00 2001 From: bjd Date: Fri, 8 Jan 2021 13:09:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9go=E7=89=88=E6=9C=AC=E4=B8=BA?= =?UTF-8?q?1.15?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/go.yml | 2 +- admin/server.go | 5 +---- base/app_ver.go | 2 +- base/cfg_server.go | 3 ++- conf/server.toml | 1 + deploy.sh | 19 ++++++++++++------- main.go | 6 ------ 7 files changed, 18 insertions(+), 20 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index bc35cb3..48216fe 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -16,7 +16,7 @@ jobs: - name: Set up Go 1.x uses: actions/setup-go@v2 with: - go-version: 1.16 + go-version: 1.15 id: go - name: Check out code into the Go module directory diff --git a/admin/server.go b/admin/server.go index bb24621..2b2ad62 100644 --- a/admin/server.go +++ b/admin/server.go @@ -2,7 +2,6 @@ package admin import ( - "embed" "net/http" "net/http/pprof" @@ -10,8 +9,6 @@ import ( "github.com/gorilla/mux" ) -var UiPath embed.FS - // 开启服务 func StartAdmin() { @@ -21,7 +18,7 @@ func StartAdmin() { r.Handle("/", http.RedirectHandler("/ui/", http.StatusFound)). Name("static") r.PathPrefix("/ui/").Handler(http.FileServer( - http.FS(UiPath), + http.Dir(base.Cfg.UiPath), )).Name("static") r.HandleFunc("/base/login", Login).Name("login") diff --git a/base/app_ver.go b/base/app_ver.go index 0f08bd7..ac15019 100644 --- a/base/app_ver.go +++ b/base/app_ver.go @@ -2,5 +2,5 @@ package base const ( APP_NAME = "AnyLink" - APP_VER = "0.0.6" + APP_VER = "0.0.7" ) diff --git a/base/cfg_server.go b/base/cfg_server.go index 280d95b..63cd41b 100644 --- a/base/cfg_server.go +++ b/base/cfg_server.go @@ -39,7 +39,8 @@ type ServerConfig struct { DbFile string `toml:"db_file" info:"数据库地址"` CertFile string `toml:"cert_file" info:"证书文件"` CertKey string `toml:"cert_key" info:"证书密钥"` - DownFilesPath string `json:"down_files_path" info:"外部下载文件路径"` + UiPath string `toml:"ui_path" info:"ui文件路径"` + DownFilesPath string `toml:"down_files_path" info:"外部下载文件路径"` LogLevel string `toml:"log_level" info:"日志等级"` Issuer string `toml:"issuer" info:"系统名称"` AdminUser string `toml:"admin_user" info:"管理用户名"` diff --git a/conf/server.toml b/conf/server.toml index 4c093e5..0be2290 100644 --- a/conf/server.toml +++ b/conf/server.toml @@ -8,6 +8,7 @@ db_file = "./data.db" #证书文件 cert_file = "./vpn_cert.pem" cert_key = "./vpn_cert.key" +ui_path = "../ui" down_files_path = "../down_files" log_level = "info" diff --git a/deploy.sh b/deploy.sh index bd78c75..cc052c6 100644 --- a/deploy.sh +++ b/deploy.sh @@ -1,23 +1,28 @@ #!/usr/bin/env bash -git clone https://github.com/bjdgyc/anylink-web.git +#编译二进制文件 +go build -o anylink -ldflags "-X main.COMMIT_ID=`git rev-parse HEAD`" +#编译前端项目 +git clone https://github.com/bjdgyc/anylink-web.git cd anylink-web +#国内可替换源加快速度 +#npm install --registry=https://registry.npm.taobao.org +#npm run build --registry=https://registry.npm.taobao.org npm install npm run build cd ../ -cp -r anylink-web/ui . -go build -o anylink -ldflags "-X main.COMMIT_ID=`git rev-parse HEAD`" #整理部署文件 mkdir anylink-deploy -cd anylink-deploy -cp -r ../anylink . -cp -r ../conf . -cp -r ../down_files . +cp -r anylink anylink-deploy +cp -r anylink-web/ui anylink-deploy +cp -r conf anylink-deploy +cp -r down_files anylink-deploy #注意使用root权限运行 +#cd anylink-deploy #sudo ./anylink -conf="conf/server.toml" diff --git a/main.go b/main.go index 624d139..7ce3137 100644 --- a/main.go +++ b/main.go @@ -2,25 +2,19 @@ package main import ( - "embed" "os" "os/signal" "syscall" - "github.com/bjdgyc/anylink/admin" "github.com/bjdgyc/anylink/base" "github.com/bjdgyc/anylink/handler" ) -//go:embed ui/* -var UiPath embed.FS - // 程序版本 var COMMIT_ID string func main() { base.CommitId = COMMIT_ID - admin.UiPath = UiPath base.Start() handler.Start()