Skip to content

Commit

Permalink
Added keep alive base URL from env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
metamemelord committed Sep 1, 2022
1 parent 5d7b4eb commit e3e9ad8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ jobs:
sudo podman run -d -p ${{ secrets.CONTAINER_EXTERNAL_PORT }}:${{ secrets.CONTAINER_INTERNAL_PORT }} \
-e GIN_MODE="${{ secrets.CONTAINER_GIN_MODE }}" \
-e KEEP_ALIVE_CRON="${{ secrets.CONTAINER_KEEP_ALIVE_CRON }}" \
-e KEEP_ALIVE_BASE_URL="${{ secrets.CONTAINER_KEEP_ALIVE_BASE_URL }}" \
-e APP_AUTH="${{ secrets.CONTAINER_APP_AUTH }}" \
-e MONGO_URI="${{ secrets.CONTAINER_MONGO_URI }}" \
-e MS_CLIENT_ID="${{ secrets.CONTAINER_MS_CLIENT_ID }}" \
Expand Down
13 changes: 11 additions & 2 deletions pkg/worker/keep_alive.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
package worker

import (
"fmt"
"log"
"net/http"
"os"
"time"
)

var healthcheckURL = "https://gaurav.dev/health"
var keepAliveBaseURL = "https://gaurav.dev"

func init() {
keepAliveBaseURLfromEnv := os.Getenv("KEEP_ALIVE_BASE_URL")
if len(keepAliveBaseURLfromEnv) > 0 {
keepAliveBaseURL = keepAliveBaseURLfromEnv
}
}

func KeepAlive(t time.Duration) {
for {
Expand All @@ -16,7 +25,7 @@ func KeepAlive(t time.Duration) {
}

func makeRequest() {
res, err := http.Get(healthcheckURL)
res, err := http.Get(fmt.Sprintf("%s/health", keepAliveBaseURL))
if err != nil {
log.Println(err)
} else {
Expand Down

0 comments on commit e3e9ad8

Please sign in to comment.