cosmium/main.go

36 lines
640 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
if config.Config.InitialDataFilePath != "" {
repositories.LoadStateFS(config.Config.InitialDataFilePath)
}
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
}