gohttp/main.go

56 lines
1.1 KiB
Go
Raw Normal View History

2023-12-07 00:22:53 +08:00
package main
import (
"net/http"
2023-12-07 22:42:27 +08:00
"os"
"os/signal"
"syscall"
2023-12-07 00:22:53 +08:00
admin "git.pyer.club/kingecg/gohttpd/admin"
2023-12-07 22:42:27 +08:00
"git.pyer.club/kingecg/gohttpd/server"
2023-12-07 00:22:53 +08:00
logger "git.pyer.club/kingecg/gologger"
)
func main() {
logger.Configure(logger.LoggersConfig{
Categories: map[string]logger.LogConfig{
"default": {
Level: "debug",
Appenders: []string{
"console",
},
},
"fat": {
Level: "debug",
Appenders: []string{
"console",
"file",
},
},
},
Appenders: map[string]logger.LogAppenderConfig{
"console": {
Type: "console",
},
"file": {
Type: "file",
Options: map[string]interface{}{
"file": "./log/fat.log",
},
},
},
})
defaultLogger := logger.GetLogger("default")
defaultLogger.Info("Listening...")
2023-12-07 22:42:27 +08:00
serverMux := server.NewRestMux("/")
serverMux.HandleMux(admin.AdminServerMux)
go http.ListenAndServe(":8080", serverMux)
defaultLogger.Debug("Next")
var waiter = make(chan os.Signal, 1) // buffered channel
signal.Notify(waiter, syscall.SIGTERM, syscall.SIGINT)
// blocks here until there's a signal
<-waiter
defaultLogger.Info("Listened")
2023-12-07 00:22:53 +08:00
}