56 lines
1.1 KiB
Go
56 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"net/http"
|
|
"os"
|
|
"os/signal"
|
|
"syscall"
|
|
|
|
admin "git.pyer.club/kingecg/gohttpd/admin"
|
|
"git.pyer.club/kingecg/gohttpd/server"
|
|
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...")
|
|
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")
|
|
}
|