move worker to seperate package (eventually seperate binary)

This commit is contained in:
2026-04-01 09:28:56 -04:00
parent c9c352204c
commit a058804603
2 changed files with 4 additions and 3 deletions

View File

@@ -13,6 +13,7 @@ import (
"time" "time"
"astraltech.xyz/accountmanager/src/logging" "astraltech.xyz/accountmanager/src/logging"
"astraltech.xyz/accountmanager/src/worker"
) )
var ( var (
@@ -365,7 +366,7 @@ func main() {
ldapServerMutex.Unlock() ldapServerMutex.Unlock()
defer closeLDAPServer(ldapServer) defer closeLDAPServer(ldapServer)
createWorker(time.Minute*5, cleanupSessions) worker.CreateWorker(time.Minute*5, cleanupSessions)
HandleFunc("/favicon.ico", faviconHandler) HandleFunc("/favicon.ico", faviconHandler)
HandleFunc("/logo", logoHandler) HandleFunc("/logo", logoHandler)

View File

@@ -1,4 +1,4 @@
package main package worker
import ( import (
"time" "time"
@@ -6,7 +6,7 @@ import (
"astraltech.xyz/accountmanager/src/logging" "astraltech.xyz/accountmanager/src/logging"
) )
func createWorker(interval time.Duration, task func()) { func CreateWorker(interval time.Duration, task func()) {
logging.Debugf("Creating worker that runs on a %s interval", interval.String()) logging.Debugf("Creating worker that runs on a %s interval", interval.String())
go func() { go func() {
ticker := time.NewTicker(interval) ticker := time.NewTicker(interval)