From 51694261ef0074a1eaf1182a93f3272d157b0e53 Mon Sep 17 00:00:00 2001 From: xiaoxuan6 <1527736751@qq.com> Date: Mon, 22 Jul 2024 13:56:57 +0800 Subject: [PATCH] fix: Update entrypoint.sh --- .dockerignore | 1 - .github/workflows/build-image.yml | 2 +- Dockerfile | 4 +++- config.cfg | 2 ++ entrypoint.sh | 4 ++-- logs/.gitea | 0 service/main.go | 8 -------- src/index.js | 6 ++++-- 8 files changed, 12 insertions(+), 15 deletions(-) create mode 100644 logs/.gitea diff --git a/.dockerignore b/.dockerignore index 52e41c1..661a728 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,5 +1,4 @@ .github/ -logs/*.log service/logs/*.log service/config.cfg .gitignore diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index dd5b96b..2150b52 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -21,5 +21,5 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} image-name: service-status - image-tags: ${{ steps.tags.outputs.VERSION }} + additional-image-tags: "${{ steps.tags.outputs.VERSION }}" custom-args: --platform=linux/arm64,linux/amd64 diff --git a/Dockerfile b/Dockerfile index 5c02e40..be7427f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,13 +19,15 @@ FROM caddy:2.4.5-alpine WORKDIR /etc/caddy COPY --link src ./src +COPY --link logs ./logs COPY --link Caddyfile config.cfg favicon.ico index.html entrypoint.sh ./ COPY --from=build-dev /go/src/app/status ./status RUN apk update && \ apk add --no-cache bash curl tzdata && \ chmod +x /etc/caddy/status && \ - chmod +x ./entrypoint.sh + chmod +x ./entrypoint.sh && \ + chmod 777 /etc/caddy/logs ENV VERBOSE=false ENV TZ=Asia/Shanghai diff --git a/config.cfg b/config.cfg index dde81a9..7bbdb1a 100644 --- a/config.cfg +++ b/config.cfg @@ -1 +1,3 @@ baidu=https://www.baidu.com +juejin=https://www.juejin.cn +juejincom=https://www.juejin.com \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh index 550e9b2..9da33c6 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,10 +1,10 @@ #!/bin/bash if [ "$VERBOSE" = "true" ]; then - nohup /etc/caddy/status > /etc/caddy/status.log 2>&1 & + nohup /etc/caddy/status > /tmp/status.log 2>&1 & sleep 3 - cat /etc/caddy/status.log + cat /tmp/status.log else nohup /etc/caddy/status > /dev/null 2>&1 & fi diff --git a/logs/.gitea b/logs/.gitea new file mode 100644 index 0000000..e69de29 diff --git a/service/main.go b/service/main.go index a77925e..9092d12 100644 --- a/service/main.go +++ b/service/main.go @@ -76,14 +76,6 @@ func run() { os.Exit(1) } - if _, err := os.Stat(dir); os.IsNotExist(err) { - err := os.Mkdir(dir, os.ModePerm) - if err != nil { - fmt.Printf("创建文件夹失败: %v\n", err) - os.Exit(1) - } - } - content, _ := os.ReadFile(configFile) f := bufio.NewReader(strings.NewReader(string(content))) for { diff --git a/src/index.js b/src/index.js index fb67796..e4efb4d 100644 --- a/src/index.js +++ b/src/index.js @@ -251,8 +251,10 @@ function splitRowsByDate(rows) { } let result = 0; - if (resultStr.trim() == "success") { - result = 1; + if (resultStr !== undefined && resultStr !== null) { + if (resultStr.trim() == "success") { + result = 1; + } } sum += result; count++;