Make sesswatch period configurable

pull/18/head
Simon Let 6 years ago
parent dc1d5e4848
commit ce7768949a
  1. 8
      cmd/daemon/main.go
  2. 1
      conf/config.toml
  3. 3
      pkg/cfg/cfg.go

@ -72,7 +72,7 @@ func main() {
if err != nil {
log.Fatal("Could not create pidfile", err)
}
runServer(config.Port, outputPath)
runServer(config, outputPath)
err = os.Remove(pidfilePath)
if err != nil {
log.Println("Could not delete pidfile", err)
@ -122,7 +122,7 @@ func (h *recordHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// fmt.Println("exit_code:", r.ExitCode)
}
func runServer(port int, outputPath string) {
func runServer(config cfg.Config, outputPath string) {
var recordSubscribers []chan records.Record
histfileChan := make(chan records.Record)
@ -132,13 +132,13 @@ func runServer(port int, outputPath string) {
sesswatchChan := make(chan records.Record)
recordSubscribers = append(recordSubscribers, sesswatchChan)
sesswatch.Go(sesswatchChan, []chan string{sessionsToDrop}, 10)
sesswatch.Go(sesswatchChan, []chan string{sessionsToDrop}, config.SesswatchPeriodSeconds)
http.HandleFunc("/status", statusHandler)
http.Handle("/record", &recordHandler{subscribers: recordSubscribers})
//http.Handle("/session_init", &sessionInitHandler{OutputPath: outputPath})
//http.Handle("/recall", &recallHandler{OutputPath: outputPath})
http.ListenAndServe(":"+strconv.Itoa(port), nil)
http.ListenAndServe(":"+strconv.Itoa(config.Port), nil)
}
func killDaemon(pidfile string) error {

@ -1 +1,2 @@
port = 2627
sesswatchPeriodSeconds = 120

@ -2,5 +2,6 @@ package cfg
// Config struct
type Config struct {
Port int
Port int
SesswatchPeriodSeconds uint
}

Loading…
Cancel
Save