()
| 123 | } |
| 124 | |
| 125 | func (s *UdpServer) loadHttpConfig() error { |
| 126 | // http.toml |
| 127 | fileName := filepath.Join(ExeDirPath, "etc", "http.toml") |
| 128 | content, err := s.loadConfigFile(fileName) |
| 129 | if err != nil { |
| 130 | log.Error("load http config err: %v", err) |
| 131 | return err |
| 132 | } |
| 133 | var httpConf HttpConfig |
| 134 | if err := toml.Unmarshal(content, &httpConf); err != nil { |
| 135 | log.Error("failed to unmarshal http config: %v", err) |
| 136 | } |
| 137 | if err = s.updateHttpConfig(httpConf); err != nil { |
| 138 | // ignore error |
| 139 | _ = err |
| 140 | } |
| 141 | |
| 142 | httpConfigWatch = utils.WatchFile(fileName, func() { |
| 143 | log.Info("http config: %s has been updated", fileName) |
| 144 | if content, err = s.loadConfigFile(fileName); err == nil { |
| 145 | if err = toml.Unmarshal(content, &httpConf); err == nil { |
| 146 | _ = s.updateHttpConfig(httpConf) |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | }) |
| 151 | return nil |
| 152 | } |
| 153 | |
| 154 | func (s *UdpServer) loadPeers() error { |
| 155 | // ac.toml |
no test coverage detected