diff options
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -4,6 +4,7 @@ import ( "os" "fmt" "flag" + "time" "errors" "strings" "path/filepath" @@ -52,6 +53,15 @@ func main() { addEndpoint(sessions, pages, e) } + // timer for inactivity log out + c := time.Tick(time.Millisecond) + go (func() { + for ;; { + _ = <-c + sessions.CleanSessions(time.Duration(conf.LoginTimeout)*time.Second) + } + })() + log.Infof("listening on %v", conf.ListenAddress) log.Fatal(http.ListenAndServe(conf.ListenAddress, nil)) } @@ -104,6 +114,10 @@ func loadConfig(filename string) config.Config { fmt.Fprintf(os.Stderr, "failed to load configuration file: %v\n", err.Error()) os.Exit(1) } + + if conf.LoginTimeout == 0 { + conf.LoginTimeout = 3600 + } return conf } |