mirror of
https://github.com/pikami/cosmium.git
synced 2025-12-19 00:40:47 +00:00
Prepare for sharedlibrary builds
This commit is contained in:
36
cmd/server/server.go
Normal file
36
cmd/server/server.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/pikami/cosmium/api"
|
||||
"github.com/pikami/cosmium/api/config"
|
||||
"github.com/pikami/cosmium/internal/repositories"
|
||||
)
|
||||
|
||||
func main() {
|
||||
config.ParseFlags()
|
||||
|
||||
repositories.InitializeRepository()
|
||||
|
||||
server := api.StartAPI()
|
||||
|
||||
waitForExit(server)
|
||||
}
|
||||
|
||||
func waitForExit(server *api.Server) {
|
||||
sigs := make(chan os.Signal, 1)
|
||||
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
|
||||
|
||||
// Block until a exit signal is received
|
||||
<-sigs
|
||||
|
||||
// Stop the server
|
||||
server.StopServer <- true
|
||||
|
||||
if config.Config.PersistDataFilePath != "" {
|
||||
repositories.SaveStateFS(config.Config.PersistDataFilePath)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user