diff options
author | 2021-03-02 22:52:31 +0100 | |
---|---|---|
committer | 2021-03-02 22:52:31 +0100 | |
commit | be1b631681ae1bc588c9002f1bedfcc01a7bb153 (patch) | |
tree | 5d66376080520cba36b7e53b5090ae12216cedc4 /cmd/server | |
parent | start implementing db interface (diff) | |
download | gotosocial-be1b631681ae1bc588c9002f1bedfcc01a7bb153.tar.xz |
More messing around
Diffstat (limited to 'cmd/server')
-rw-r--r-- | cmd/server/main.go | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/cmd/server/main.go b/cmd/server/main.go index fded184fa..7a509e96f 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -19,10 +19,42 @@ package main import ( - "github.com/gotosocial/gotosocial/internal/client" + "context" + "os" + "os/signal" + "syscall" + + "github.com/gotosocial/gotosocial/internal/db" + "github.com/sirupsen/logrus" ) func main() { - router := client.NewRouter() - router.Route() + log := logrus.New() + ctx := context.Background() + dbConfig := &db.Config{ + Type: "POSTGRES", + Address: "", + Port: 5432, + User: "", + Password: "whatever", + Database: "postgres", + ApplicationName: "gotosocial", + } + dbService, err := db.NewService(ctx, dbConfig, log) + if err != nil { + panic(err) + } + + // catch shutdown signals from the operating system + sigs := make(chan os.Signal, 1) + signal.Notify(sigs, os.Interrupt, syscall.SIGTERM) + sig := <-sigs + log.Infof("received signal %s, shutting down", sig) + + // close down all running services in order + if err := dbService.Stop(ctx); err != nil { + log.Errorf("error closing dbservice: %s", err) + } + + log.Info("done! exiting...") } |