farside/main.go
Ben Busby 6970db9c5b
Some checks are pending
Tests / test (1.21.x, macos-latest) (push) Waiting to run
Tests / test (1.21.x, ubuntu-latest) (push) Waiting to run
Tests / test (1.21.x, windows-latest) (push) Waiting to run
Tests / test (1.22.x, macos-latest) (push) Waiting to run
Tests / test (1.22.x, ubuntu-latest) (push) Waiting to run
Tests / test (1.22.x, windows-latest) (push) Waiting to run
Tests / test (1.23.x, macos-latest) (push) Waiting to run
Tests / test (1.23.x, ubuntu-latest) (push) Waiting to run
Tests / test (1.23.x, windows-latest) (push) Waiting to run
Run cron init in goroutine
Cron init blocks the server from starting until it finishes, which is
not ideal.
2025-02-26 12:38:18 -07:00

40 lines
593 B
Go

package main
import (
"log"
"os"
"os/signal"
"syscall"
"github.com/benbusby/farside/db"
"github.com/benbusby/farside/server"
"github.com/benbusby/farside/services"
)
func main() {
err := db.InitializeDB()
if err != nil {
log.Fatal(err)
}
go func() {
err = services.InitializeServices()
if err != nil {
log.Println("Error intializing services", err)
}
}()
go db.InitCronTasks()
signalChan := make(chan os.Signal, 1)
signal.Notify(signalChan, os.Interrupt, syscall.SIGTERM)
go func() {
<-signalChan
_ = db.CloseDB()
os.Exit(0)
}()
server.RunServer()
}