Skip to content

Commit

Permalink
Merge pull request #666 from flatcar/skoeva/bg-job-fix
Browse files Browse the repository at this point in the history
backend: Change default interval for instance stats query
  • Loading branch information
skoeva authored Aug 10, 2023
2 parents 3eddf31 + 2b0f447 commit 9b8f17b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion backend/pkg/api/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const (

const (
validityInterval postgresDuration = "1 days"
defaultInterval time.Duration = time.Hour
defaultInterval time.Duration = 2 * time.Hour
)

// Instance represents an instance running one or more applications for which
Expand Down
5 changes: 3 additions & 2 deletions backend/pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,12 @@ func New(conf *config.Config, db *db.API) (*echo.Echo, error) {

// setup background job for updating instance stats
go func() {
err := db.UpdateInstanceStats(nil, nil)
// update once at startup
err = db.UpdateInstanceStats(nil, nil)
if err != nil {
logger.Err(err).Msg("Error updating instance stats")
}
ticker := time.NewTicker(db.GetDefaultInterval())
ticker := time.NewTicker(time.Hour)
defer ticker.Stop()

for range ticker.C {
Expand Down

0 comments on commit 9b8f17b

Please sign in to comment.