2024-02-10 15:17:34 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2024-02-25 20:13:04 +00:00
|
|
|
"os"
|
|
|
|
"os/signal"
|
|
|
|
"syscall"
|
2024-02-10 15:17:34 +00:00
|
|
|
|
|
|
|
"github.com/pikami/cosmium/api"
|
2024-02-13 23:47:51 +00:00
|
|
|
"github.com/pikami/cosmium/api/config"
|
2024-02-14 18:46:40 +00:00
|
|
|
"github.com/pikami/cosmium/internal/repositories"
|
2024-02-10 15:17:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2024-02-13 23:47:51 +00:00
|
|
|
config.ParseFlags()
|
2024-02-10 15:17:34 +00:00
|
|
|
|
2024-02-27 20:11:33 +00:00
|
|
|
repositories.InitializeRepository()
|
2024-02-14 18:46:40 +00:00
|
|
|
|
2024-02-27 19:58:57 +00:00
|
|
|
go api.StartAPI()
|
2024-02-25 20:13:04 +00:00
|
|
|
|
|
|
|
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
|
|
|
}
|