Skip to content

Commit

Permalink
auto reboot if cert updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Distortions81 committed Apr 15, 2024
1 parent 7d10da7 commit 650122d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ FactBanSync
composite-banlist.json
data/logs
data/banCache/
data/server.crt
data/server.key
2 changes: 1 addition & 1 deletion glob.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"time"
)

const ProgVersion string = "0.0.208"
const ProgVersion string = "0.0.209"

// Globals
var (
Expand Down
31 changes: 31 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package main
import (
"flag"
"log"
"os"
"time"
)

func main() {
Expand Down Expand Up @@ -61,5 +63,34 @@ func main() {

startWebserver()

go func() {
for {
time.Sleep(time.Second * 5)

initialStat, erra := os.Stat(serverConfig.WebServer.SSLCertFile)

if erra != nil {
continue
}

for initialStat != nil {
time.Sleep(time.Second * 5)

stat, errb := os.Stat(serverConfig.WebServer.SSLCertFile)
if errb != nil {
break
}

if stat.Size() != initialStat.Size() || stat.ModTime() != initialStat.ModTime() {
log.Println("Cert updated, closing.")
time.Sleep(time.Second * 5)
os.Exit(0)
break
}
}

}
}()

mainLoop()
}

0 comments on commit 650122d

Please sign in to comment.