mirror of
https://github.com/benbusby/farside.git
synced 2025-03-15 11:46:32 -04:00

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
Cron init blocks the server from starting until it finishes, which is not ideal.
40 lines
593 B
Go
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()
|
|
}
|