Skip to content

Commit d89392e

Browse files
committed
Perform maintenance as the last thing before starting the Web server
1 parent 1a45c1b commit d89392e

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/main.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,6 @@ func main() {
9494
slog.SetDefault(slog.New(slogdb.NewDBHandler(tintHandler, db.Pool)))
9595
slog.Info("Database error logging enabled")
9696

97-
// Set up cron task for routine maintenance.
98-
go func() {
99-
// Do a one-off cleanup before scheduling a recurring task.
100-
performMaintenance()
101-
ticker := time.Tick(2 * time.Hour)
102-
for {
103-
<-ticker
104-
performMaintenance()
105-
}
106-
}()
107-
10897
// Set up a graceful cleanup for when the process is terminated.
10998
signalCh := make(chan os.Signal, 1)
11099
signal.Notify(signalCh, os.Interrupt, syscall.SIGTERM, syscall.SIGINT)
@@ -128,6 +117,17 @@ func main() {
128117
github.Init(mux)
129118
dashboard.Init(mux)
130119

120+
// Set up cron task for routine maintenance.
121+
go func() {
122+
// Do a one-off cleanup before scheduling a recurring task.
123+
performMaintenance()
124+
ticker := time.Tick(2 * time.Hour)
125+
for {
126+
<-ticker
127+
performMaintenance()
128+
}
129+
}()
130+
131131
addr := net.JoinHostPort("", strconv.Itoa(conf.Config.Web.Port))
132132
slog.Info("Listening", "url", "http://localhost"+addr) // Not "https://", since this app does not terminate SSL.
133133
log.Fatal(http.ListenAndServe(addr, core.SecurityHeaders(mux)))

0 commit comments

Comments
 (0)