main.go 1008 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package main
  2. import (
  3. "fmt"
  4. "log"
  5. "git.ali33.ru/fcg-xvii/go-tools/text/config"
  6. _ "git.ali33.ru/fcg-xvii/go-tools/text/config/ini"
  7. "git.ali33.ru/fcg-xvii/net/v3/http/server"
  8. )
  9. var (
  10. listen = "127.0.0.1:33775"
  11. debugMode = false
  12. downTime = 5
  13. )
  14. func main() {
  15. appConf, err := config.FromFile("ini", "config.ini")
  16. if err == nil {
  17. listen = appConf.ValueDefault("listen", listen).(string)
  18. debugMode = appConf.ValueDefault("debug_mode", debugMode).(bool)
  19. downTime = appConf.ValueDefault("downtime", downTime).(int)
  20. }
  21. log.Println("listen", listen)
  22. log.Println("debug_mode", debugMode)
  23. log.Println("downtime", downTime)
  24. if !debugMode {
  25. openURI(fmt.Sprintf("http://%s", listen))
  26. }
  27. // запуск сервера
  28. conf := server.ConfigDefault()
  29. conf.Addr = listen
  30. conf.App = NewApplication(listen)
  31. serv := server.NewServerHTTP(conf)
  32. go serv.Start(func(s server.Server, started bool, err error) {
  33. log.Println(s, started, err)
  34. })
  35. mainChan := make(chan struct{})
  36. <-mainChan
  37. }