Initial commit.
This commit is contained in:
49
cmd/fastpastebin/fastpastebin.go
Normal file
49
cmd/fastpastebin/fastpastebin.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
// stdlib
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
// local
|
||||
"github.com/pztrn/fastpastebin/api"
|
||||
"github.com/pztrn/fastpastebin/context"
|
||||
"github.com/pztrn/fastpastebin/database"
|
||||
"github.com/pztrn/fastpastebin/database/migrations"
|
||||
)
|
||||
|
||||
func main() {
|
||||
c := context.New()
|
||||
c.Initialize()
|
||||
|
||||
c.Logger.Info().Msg("Starting Fast Pastebin...")
|
||||
|
||||
// Here goes initial initialization for packages that want CLI flags
|
||||
// to be added.
|
||||
|
||||
// Parse flags.
|
||||
c.Flagger.Parse()
|
||||
|
||||
// Continue loading.
|
||||
c.LoadConfiguration()
|
||||
database.New(c)
|
||||
c.Database.Initialize()
|
||||
migrations.New(c)
|
||||
migrations.Migrate()
|
||||
api.New(c)
|
||||
api.InitializeAPI()
|
||||
|
||||
// CTRL+C handler.
|
||||
signalHandler := make(chan os.Signal, 1)
|
||||
shutdownDone := make(chan bool, 1)
|
||||
signal.Notify(signalHandler, os.Interrupt, syscall.SIGTERM)
|
||||
go func() {
|
||||
<-signalHandler
|
||||
c.Shutdown()
|
||||
shutdownDone <- true
|
||||
}()
|
||||
|
||||
<-shutdownDone
|
||||
os.Exit(0)
|
||||
}
|
Reference in New Issue
Block a user