Skip to content

Commit

Permalink
支持旧版本升级
Browse files Browse the repository at this point in the history
  • Loading branch information
ouqiang committed May 20, 2018
1 parent 4f7a5cf commit 0e023bd
Show file tree
Hide file tree
Showing 43 changed files with 78 additions and 2,282 deletions.
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ RUN make install-vue \

FROM alpine:3.7

RUN addgroup -S app \
RUN apk add --no-cache ca-certificates \
&& addgroup -S app \
&& adduser -S -g app app

WORKDIR /app
Expand All @@ -27,4 +28,4 @@ EXPOSE 5920

USER app

ENTRYPOINT ["/app/gocron", "web"]
ENTRYPOINT ["/app/gocron", "web"]
2 changes: 2 additions & 0 deletions internal/models/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ func (m *Migration) upgradeFor150(session *xorm.Session) error {
return err
}

settingModel.Id = 0
settingModel.Code = WebhookCode
settingModel.Key = WebhookUrlKey
settingModel.Value = ""
Expand All @@ -231,6 +232,7 @@ func (m *Migration) upgradeFor150(session *xorm.Session) error {
return err
}

settingModel.Id = 0
settingModel.Code = WebhookCode
settingModel.Key = WebhookTemplateKey
settingModel.Value = webhookTemplate
Expand Down
7 changes: 2 additions & 5 deletions internal/modules/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ var (
ConfDir string // 配置目录
// LogDir 日志目录
LogDir string // 日志目录
// DataDir 数据目录
DataDir string // 存放session等
// AppConfig 配置文件
AppConfig string // 应用配置文件
// Installed 应用是否已安装
Expand All @@ -46,10 +44,9 @@ func InitEnv(versionString string) {
}
ConfDir = filepath.Join(AppDir, "/conf")
LogDir = filepath.Join(AppDir, "/log")
DataDir = filepath.Join(AppDir, "/data")
AppConfig = filepath.Join(ConfDir, "/app.ini")
VersionFile = filepath.Join(ConfDir, "/.version")
createDirIfNotExists(ConfDir, LogDir, DataDir)
createDirIfNotExists(ConfDir, LogDir)
Installed = IsInstalled()
VersionId = ToNumberVersion(versionString)
}
Expand Down Expand Up @@ -107,7 +104,7 @@ func GetCurrentVersionId() int {

// ToNumberVersion 把字符串版本号a.b.c转换为整数版本号abc
func ToNumberVersion(versionString string) int {
if strings.HasPrefix("v", versionString) {
if strings.HasPrefix(versionString, "v") {
versionString = versionString[1:]
}
v := strings.Replace(versionString, ".", "", -1)
Expand Down
11 changes: 6 additions & 5 deletions internal/routers/routers.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ import (
_ "github.com/ouqiang/gocron/internal/statik"
)

// URL前缀
const urlPrefix = "/api"

var staticDir = "public"
const (
urlPrefix = "/api"
staticDir = "public"
)

var statikFS http.FileSystem

Expand All @@ -42,7 +42,7 @@ func init() {
}
}

// 路由注册
// Register 路由注册
func Register(m *macaron.Macaron) {
m.SetURLPrefix(urlPrefix)
// 所有GET方法,自动注册HEAD方法
Expand All @@ -54,6 +54,7 @@ func Register(m *macaron.Macaron) {
ctx.WriteHeader(http.StatusInternalServerError)
return
}

io.Copy(ctx.Resp, file)

})
Expand Down
5 changes: 4 additions & 1 deletion internal/routers/user/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func Index(ctx *macaron.Context) string {

// 解析查询参数
func parseQueryParams(ctx *macaron.Context) models.CommonMap {
var params models.CommonMap = models.CommonMap{}
params := models.CommonMap{}
base.ParsePageAndPageSize(ctx, params)

return params
Expand All @@ -65,6 +65,9 @@ func Detail(ctx *macaron.Context) string {
logger.Error(err)
}
jsonResp := utils.JsonResponse{}
if userModel.Id == 0 {
return jsonResp.Success(utils.SuccessContent, nil)
}

return jsonResp.Success(utils.SuccessContent, userModel)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/service/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func (task Task) Initialize() {
for page < maxPage {
taskList, err := taskModel.ActiveList(page, pageSize)
if err != nil {
logger.Fatalf("定时任务初始化#获取任务列表错误-", err.Error())
logger.Fatalf("定时任务初始化#获取任务列表错误: %s", err)
}
if len(taskList) == 0 {
break
Expand Down
2 changes: 1 addition & 1 deletion internal/statik/statik.go

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


.PHONY: build
build: gocron node

Expand Down Expand Up @@ -41,6 +39,10 @@ enable-race:
package: build-vue statik
bash ./package.sh

.PHONY: package-all
package-all: build-vue statik
bash ./package.sh -p 'linux darwin windows'

.PHONY: build-vue
build-vue:
cd web/vue && yarn run build
Expand Down
6 changes: 3 additions & 3 deletions package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ init() {
GIT_COMMIT_ID=`git_latest_commit`
LDFLAGS="-w -X 'main.AppVersion=${VERSION}' -X 'main.BuildDate=`date '+%Y-%m-%d %H:%M:%S'`' -X 'main.GitCommit=${GIT_COMMIT_ID}'"

PACKAGE_DIR=${BINARY_NAME}_package
BUILD_DIR=${BINARY_NAME}_build
PACKAGE_DIR=${BINARY_NAME}-package
BUILD_DIR=${BINARY_NAME}-build

if [[ -d ${BUILD_DIR} ]];then
rm -rf ${BUILD_DIR}
Expand Down Expand Up @@ -178,7 +178,7 @@ run() {
package_gocron() {
BINARY_NAME='gocron'
MAIN_FILE="./cmd/gocron/gocron.go"
INCLUDE_FILE=(Dockerfile-release README.md)
INCLUDE_FILE=()


run
Expand Down
25 changes: 0 additions & 25 deletions web/templates/common/footer.html

This file was deleted.

72 changes: 0 additions & 72 deletions web/templates/common/header.html

This file was deleted.

41 changes: 0 additions & 41 deletions web/templates/common/pagination.html

This file was deleted.

12 changes: 0 additions & 12 deletions web/templates/error/404.html

This file was deleted.

11 changes: 0 additions & 11 deletions web/templates/error/500.html

This file was deleted.

3 changes: 0 additions & 3 deletions web/templates/home/index.html

This file was deleted.

Loading

0 comments on commit 0e023bd

Please sign in to comment.