Server and client stubs.
Implemented HTTP server with configuration getting stub. Implemented CLI client with configuration getting stub.
This commit is contained in:
36
cmd/giredorectl/main.go
Normal file
36
cmd/giredorectl/main.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
// stdlib
|
||||
"os"
|
||||
|
||||
// local
|
||||
"sources.dev.pztrn.name/pztrn/giredore/domains/client/v1"
|
||||
"sources.dev.pztrn.name/pztrn/giredore/internal/logger"
|
||||
|
||||
// other
|
||||
"github.com/teris-io/cli"
|
||||
)
|
||||
|
||||
func main() {
|
||||
config := cli.NewCommand("configuration", "work with giredore server configuration").
|
||||
WithShortcut("conf").
|
||||
WithCommand(
|
||||
cli.NewCommand("get", "gets and prints out current giredore server configuration").
|
||||
WithAction(func(args []string, options map[string]string) int {
|
||||
logger.Initialize()
|
||||
clientv1.Initialize()
|
||||
clientv1.GetConfiguration(options)
|
||||
|
||||
return 0
|
||||
}),
|
||||
)
|
||||
|
||||
app := cli.New("giredore server controlling utility").
|
||||
WithOption(
|
||||
cli.NewOption("server", "giredore server address"),
|
||||
).
|
||||
WithCommand(config)
|
||||
|
||||
os.Exit(app.Run(os.Args, os.Stdout))
|
||||
}
|
41
cmd/giredored/main.go
Normal file
41
cmd/giredored/main.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
// stdlib
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
// local
|
||||
"sources.dev.pztrn.name/pztrn/giredore/domains/server/v1"
|
||||
"sources.dev.pztrn.name/pztrn/giredore/internal/configuration"
|
||||
"sources.dev.pztrn.name/pztrn/giredore/internal/httpserver"
|
||||
"sources.dev.pztrn.name/pztrn/giredore/internal/logger"
|
||||
)
|
||||
|
||||
func main() {
|
||||
logger.Initialize()
|
||||
logger.Logger.Info().Msg("Starting giredore server...")
|
||||
|
||||
configuration.Initialize()
|
||||
httpserver.Initialize()
|
||||
|
||||
serverv1.Initialize()
|
||||
|
||||
httpserver.Start()
|
||||
|
||||
logger.Logger.Info().Msg("giredore server is ready")
|
||||
|
||||
// CTRL+C handler.
|
||||
signalHandler := make(chan os.Signal, 1)
|
||||
shutdownDone := make(chan bool, 1)
|
||||
signal.Notify(signalHandler, os.Interrupt, syscall.SIGTERM)
|
||||
go func() {
|
||||
<-signalHandler
|
||||
httpserver.Shutdown()
|
||||
shutdownDone <- true
|
||||
}()
|
||||
|
||||
<-shutdownDone
|
||||
os.Exit(0)
|
||||
}
|
Reference in New Issue
Block a user