aboutsummaryrefslogtreecommitdiff
path: root/cmd/koushin
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2020-05-13 14:07:44 +0200
committerSimon Ser <contact@emersion.fr>2020-05-13 14:07:44 +0200
commitb891a95fcf4a3d4b64100911dae49fb28904a7fd (patch)
treefe07b29d6f2443047b7f740c79d86b3c499cc9e9 /cmd/koushin
parent4cf5ad68afd80f27512c464843b0d917182ef0c2 (diff)
downloadalps-b891a95fcf4a3d4b64100911dae49fb28904a7fd.tar.gz
alps-b891a95fcf4a3d4b64100911dae49fb28904a7fd.zip
Rename project to alps
Diffstat (limited to 'cmd/koushin')
-rw-r--r--cmd/koushin/main.go74
1 files changed, 0 insertions, 74 deletions
diff --git a/cmd/koushin/main.go b/cmd/koushin/main.go
deleted file mode 100644
index d9edfc9..0000000
--- a/cmd/koushin/main.go
+++ /dev/null
@@ -1,74 +0,0 @@
-package main
-
-import (
- "flag"
- "fmt"
- "os"
- "os/signal"
- "syscall"
-
- "git.sr.ht/~emersion/koushin"
- "github.com/labstack/echo/v4"
- "github.com/labstack/echo/v4/middleware"
- "github.com/labstack/gommon/log"
-
- _ "git.sr.ht/~emersion/koushin/plugins/base"
- _ "git.sr.ht/~emersion/koushin/plugins/caldav"
- _ "git.sr.ht/~emersion/koushin/plugins/carddav"
- _ "git.sr.ht/~emersion/koushin/plugins/lua"
- _ "git.sr.ht/~emersion/koushin/plugins/viewhtml"
- _ "git.sr.ht/~emersion/koushin/plugins/viewtext"
-)
-
-func main() {
- var options koushin.Options
- var addr string
- flag.StringVar(&options.Theme, "theme", "", "default theme")
- flag.StringVar(&addr, "addr", ":1323", "listening address")
- flag.BoolVar(&options.Debug, "debug", false, "enable debug logs")
-
- flag.Usage = func() {
- fmt.Fprintf(flag.CommandLine.Output(), "usage: koushin [options...] <upstream servers...>\n")
- flag.PrintDefaults()
- }
-
- flag.Parse()
-
- options.Upstreams = flag.Args()
- if len(options.Upstreams) == 0 {
- flag.Usage()
- return
- }
-
- e := echo.New()
- e.HideBanner = true
- if l, ok := e.Logger.(*log.Logger); ok {
- l.SetHeader("${time_rfc3339} ${level}")
- }
- s, err := koushin.New(e, &options)
- if err != nil {
- e.Logger.Fatal(err)
- }
- e.Use(middleware.Recover())
- if options.Debug {
- e.Use(middleware.LoggerWithConfig(middleware.LoggerConfig{
- Format: "${time_rfc3339} method=${method}, uri=${uri}, status=${status}\n",
- }))
- }
-
- if options.Debug {
- e.Logger.SetLevel(log.DEBUG)
- }
-
- sigs := make(chan os.Signal, 1)
- signal.Notify(sigs, syscall.SIGUSR1)
- go func() {
- for range sigs {
- if err := s.Reload(); err != nil {
- e.Logger.Errorf("Failed to reload server: %v", err)
- }
- }
- }()
-
- e.Logger.Fatal(e.Start(addr))
-}