cosmium/main.go

34 lines
566 B
Go
Raw Normal View History

2024-02-10 15:17:34 +00:00
package main
import (
"os"
"os/signal"
"syscall"
2024-02-10 15:17:34 +00:00
"github.com/pikami/cosmium/api"
"github.com/pikami/cosmium/api/config"
"github.com/pikami/cosmium/internal/repositories"
2024-02-10 15:17:34 +00:00
)
func main() {
config.ParseFlags()
2024-02-10 15:17:34 +00:00
repositories.InitializeRepository()
2024-02-27 19:58:57 +00:00
go api.StartAPI()
waitForExit()
}
func waitForExit() {
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
// Block until a exit signal is received
<-sigs
if config.Config.PersistDataFilePath != "" {
repositories.SaveStateFS(config.Config.PersistDataFilePath)
}
2024-02-10 15:17:34 +00:00
}