From 1b68476b81fb2fdc77ca8d5cb47e0bf4d3fcfdb9 Mon Sep 17 00:00:00 2001 From: hunterlong Date: Wed, 10 Jun 2020 23:11:39 -0700 Subject: [PATCH] urgent bug fix 100% CPU, pprof with DEBUG env, --- .github/workflows/master.yml | 310 +++++++++++++++++------------------ CHANGELOG.md | 2 + handlers/cache.go | 2 +- handlers/handlers.go | 2 - handlers/routes.go | 2 +- types/services/routine.go | 2 - utils/env.go | 1 + 7 files changed, 160 insertions(+), 161 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 823e364b..d3f14b46 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -143,160 +143,160 @@ jobs: env: COVERALLS: ${{ secrets.COVERALLS }} -# test-postman-sqlite: -# needs: compile -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@v2 -# - uses: actions/setup-go@v2 -# with: -# go-version: '1.14.2' -# -# - name: Setting ENV's -# run: | -# echo "::add-path::$(go env GOPATH)/bin" -# echo "::add-path::/opt/hostedtoolcache/node/10.20.1/x64/bin" -# echo ::set-env name=VERSION::$(cat version.txt) -# shell: bash -# -# - name: Download Compiled Frontend (rice-box.go) -# uses: actions/download-artifact@v1 -# with: -# name: static-rice-box -# path: ./source -# -# - name: Install Statping -# env: -# VERSION: ${{ env.VERSION }} -# run: | -# make build -# chmod +x statping -# mv statping $(go env GOPATH)/bin/ -# -# - name: Run Statping -# run: | -# API_SECRET=demosecret123 statping --port=8585 > /dev/null & -# sleep 5 -# -# - name: Postman SQLite Tests -# uses: matt-ball/newman-action@master -# with: -# apiKey: ${{ secrets.POSTMAN_API }} -# collection: ./dev/postman.json -# environment: ./dev/postman_env_sqlite.json -# timeoutRequest: 30000 -# delayRequest: 600 -# -# test-postman-mysql: -# needs: compile -# runs-on: ubuntu-latest -# -# services: -# mysql: -# image: mysql:5.7 -# env: -# MYSQL_ROOT_PASSWORD: password123 -# MYSQL_DATABASE: statping -# ports: -# - 3306:3306 -# options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 -# -# steps: -# - uses: actions/checkout@v2 -# - uses: actions/setup-go@v2 -# with: -# go-version: '1.14.2' -# -# - name: Setting ENV's -# run: | -# echo "::add-path::$(go env GOPATH)/bin" -# echo "::add-path::/opt/hostedtoolcache/node/10.20.1/x64/bin" -# echo ::set-env name=VERSION::$(cat version.txt) -# shell: bash -# -# - name: Download Compiled Frontend (rice-box.go) -# uses: actions/download-artifact@v1 -# with: -# name: static-rice-box -# path: ./source -# -# - name: Install Statping -# env: -# VERSION: ${{ env.VERSION }} -# run: | -# make build -# chmod +x statping -# mv statping $(go env GOPATH)/bin/ -# -# - name: Run Statping -# run: | -# API_SECRET=demosecret123 statping --port=8585 > /dev/null & -# sleep 5 -# -# - name: Postman MySQL Tests -# uses: matt-ball/newman-action@master -# with: -# apiKey: ${{ secrets.POSTMAN_API }} -# collection: ./dev/postman.json -# environment: ./dev/postman_env_mysql.json -# timeoutRequest: 30000 -# delayRequest: 600 -# -# test-postman-postgres: -# needs: compile -# runs-on: ubuntu-latest -# -# services: -# postgres: -# image: postgres:10.8 -# env: -# POSTGRES_USER: root -# POSTGRES_PASSWORD: password123 -# POSTGRES_DB: statping -# ports: -# - 5432:5432 -# options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 -# -# steps: -# - uses: actions/checkout@v2 -# - uses: actions/setup-go@v2 -# with: -# go-version: '1.14.2' -# -# - name: Setting ENV's -# run: | -# echo "::add-path::$(go env GOPATH)/bin" -# echo "::add-path::/opt/hostedtoolcache/node/10.20.1/x64/bin" -# echo ::set-env name=VERSION::$(cat version.txt) -# shell: bash -# -# - name: Download Compiled Frontend (rice-box.go) -# uses: actions/download-artifact@v1 -# with: -# name: static-rice-box -# path: ./source -# -# - name: Install Statping -# env: -# VERSION: ${{ env.VERSION }} -# run: | -# make build -# chmod +x statping -# mv statping $(go env GOPATH)/bin/ -# -# - name: Run Statping -# run: | -# API_SECRET=demosecret123 statping --port=8585 > /dev/null & -# sleep 5 -# -# - name: Postman Postgres Tests -# uses: matt-ball/newman-action@master -# with: -# apiKey: ${{ secrets.POSTMAN_API }} -# collection: ./dev/postman.json -# environment: ./dev/postman_env_postgres.json -# timeoutRequest: 30000 -# delayRequest: 600 + test-postman-sqlite: + needs: compile + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-go@v2 + with: + go-version: '1.14.2' + + - name: Setting ENV's + run: | + echo "::add-path::$(go env GOPATH)/bin" + echo "::add-path::/opt/hostedtoolcache/node/10.20.1/x64/bin" + echo ::set-env name=VERSION::$(cat version.txt) + shell: bash + + - name: Download Compiled Frontend (rice-box.go) + uses: actions/download-artifact@v1 + with: + name: static-rice-box + path: ./source + + - name: Install Statping + env: + VERSION: ${{ env.VERSION }} + run: | + make build + chmod +x statping + mv statping $(go env GOPATH)/bin/ + + - name: Run Statping + run: | + API_SECRET=demosecret123 statping --port=8585 > /dev/null & + sleep 5 + + - name: Postman SQLite Tests + uses: matt-ball/newman-action@master + with: + apiKey: ${{ secrets.POSTMAN_API }} + collection: ./dev/postman.json + environment: ./dev/postman_env_sqlite.json + timeoutRequest: 30000 + delayRequest: 600 + + test-postman-mysql: + needs: compile + runs-on: ubuntu-latest + + services: + mysql: + image: mysql:5.7 + env: + MYSQL_ROOT_PASSWORD: password123 + MYSQL_DATABASE: statping + ports: + - 3306:3306 + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-go@v2 + with: + go-version: '1.14.2' + + - name: Setting ENV's + run: | + echo "::add-path::$(go env GOPATH)/bin" + echo "::add-path::/opt/hostedtoolcache/node/10.20.1/x64/bin" + echo ::set-env name=VERSION::$(cat version.txt) + shell: bash + + - name: Download Compiled Frontend (rice-box.go) + uses: actions/download-artifact@v1 + with: + name: static-rice-box + path: ./source + + - name: Install Statping + env: + VERSION: ${{ env.VERSION }} + run: | + make build + chmod +x statping + mv statping $(go env GOPATH)/bin/ + + - name: Run Statping + run: | + API_SECRET=demosecret123 statping --port=8585 > /dev/null & + sleep 5 + + - name: Postman MySQL Tests + uses: matt-ball/newman-action@master + with: + apiKey: ${{ secrets.POSTMAN_API }} + collection: ./dev/postman.json + environment: ./dev/postman_env_mysql.json + timeoutRequest: 30000 + delayRequest: 600 + + test-postman-postgres: + needs: compile + runs-on: ubuntu-latest + + services: + postgres: + image: postgres:10.8 + env: + POSTGRES_USER: root + POSTGRES_PASSWORD: password123 + POSTGRES_DB: statping + ports: + - 5432:5432 + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-go@v2 + with: + go-version: '1.14.2' + + - name: Setting ENV's + run: | + echo "::add-path::$(go env GOPATH)/bin" + echo "::add-path::/opt/hostedtoolcache/node/10.20.1/x64/bin" + echo ::set-env name=VERSION::$(cat version.txt) + shell: bash + + - name: Download Compiled Frontend (rice-box.go) + uses: actions/download-artifact@v1 + with: + name: static-rice-box + path: ./source + + - name: Install Statping + env: + VERSION: ${{ env.VERSION }} + run: | + make build + chmod +x statping + mv statping $(go env GOPATH)/bin/ + + - name: Run Statping + run: | + API_SECRET=demosecret123 statping --port=8585 > /dev/null & + sleep 5 + + - name: Postman Postgres Tests + uses: matt-ball/newman-action@master + with: + apiKey: ${{ secrets.POSTMAN_API }} + collection: ./dev/postman.json + environment: ./dev/postman_env_postgres.json + timeoutRequest: 30000 + delayRequest: 600 build-binaries: needs: compile @@ -361,7 +361,7 @@ jobs: path: ./build upload-release: - needs: [test, build-binaries] + needs: [test, test-postman-sqlite, test-postman-mysql, test-postman-postgres, build-binaries] runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 diff --git a/CHANGELOG.md b/CHANGELOG.md index 420926ae..c2ca4d17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ # 0.90.47 (06-10-2020) +- Fixed Urgent bug taking 100% of CPU (Timer) - Modified HTTP server, now in it's own go routine/channel - Fixed Service form for editing - Added pprof golang debugging http server if `GO_ENV` == "test" @@ -8,6 +9,7 @@ - Added `LOGS_MAX_COUNT` - Added `LOGS_MAX_AGE` - Added `LOGS_MAX_SIZE` +- Added `DEBUG` (starts a pprof golang debugging http server on port 9090, defaults to false) - Confirmed `DISABLE_LOGS` is working - Modified Mobile Notifier to fit new push notification server endpoint - PR Merged: Fix time conversion in overview and charts #645 diff --git a/handlers/cache.go b/handlers/cache.go index a3369a10..82de3e60 100644 --- a/handlers/cache.go +++ b/handlers/cache.go @@ -34,12 +34,12 @@ CacheRoutine: case <-s.running: break CacheRoutine case <-time.After(duration): - duration = 5 * time.Second for k, v := range s.List() { if v.Expired() { s.Delete(k) } } + duration = 5 * time.Second } } } diff --git a/handlers/handlers.go b/handlers/handlers.go index 6ee81ad6..10811c9d 100644 --- a/handlers/handlers.go +++ b/handlers/handlers.go @@ -67,8 +67,6 @@ func RunHTTPServer() error { select { case err := <-httpError: return err - default: - } } } diff --git a/handlers/routes.go b/handlers/routes.go index c91b842d..54ad971c 100644 --- a/handlers/routes.go +++ b/handlers/routes.go @@ -49,7 +49,7 @@ func Router() *mux.Router { r.Use(sendLog) } - if utils.Params.GetString("GO_ENV") == "test" { + if utils.Params.GetBool("DEBUG") { go func() { log.Infoln("Starting pprof web server on http://0.0.0.0:9090") r := http.NewServeMux() diff --git a/types/services/routine.go b/types/services/routine.go index 82915a9f..9924f58e 100644 --- a/types/services/routine.go +++ b/types/services/routine.go @@ -47,8 +47,6 @@ CheckLoop: } else { s.SleepDuration = s.Checkpoint.Sub(time.Now()) } - default: - } } } diff --git a/utils/env.go b/utils/env.go index 7236e03f..54b53e5c 100644 --- a/utils/env.go +++ b/utils/env.go @@ -30,6 +30,7 @@ func InitEnvs() { Params.SetDefault("DISABLE_HTTP", false) Params.SetDefault("STATPING_DIR", defaultDir) Params.SetDefault("GO_ENV", "production") + Params.SetDefault("DEBUG", false) Params.SetDefault("DB_CONN", "") Params.SetDefault("DISABLE_LOGS", false) Params.SetDefault("USE_ASSETS", false)