code refactoring

This commit is contained in:
2023-05-31 10:21:30 +02:00
parent cfd6b78695
commit 78c1559e84
3 changed files with 12 additions and 12 deletions

View File

@@ -81,8 +81,8 @@ func RunBlocking(port int, frontend fs.FS) {
app.Server().StreamRequestBody = true
go periodicallyPersist()
go gracefulShutdown(app)
go autoPersist(time.Minute * 5)
log.Fatal(app.Listen(fmt.Sprintf(":%d", port)))
}
@@ -106,9 +106,9 @@ func gracefulShutdown(app *fiber.App) {
}()
}
func periodicallyPersist() {
func autoPersist(d time.Duration) {
for {
db.Persist()
time.Sleep(time.Minute * 5)
time.Sleep(d)
}
}