(adapterAddr string, adapterUseMirrorAddr string)
| 54 | } |
| 55 | |
| 56 | func startAdapterServer(adapterAddr string, adapterUseMirrorAddr string) func() { |
| 57 | adapterHTTPServer, err := adapter.NewHTTPAdapter(adapterAddr, configFile, adapterUseMirrorAddr) |
| 58 | if err != nil { |
| 59 | ConsoleLog.WithError(err).Error("init adapter failed") |
| 60 | SetExitStatus(1) |
| 61 | return nil |
| 62 | } |
| 63 | |
| 64 | if err = adapterHTTPServer.Serve(); err != nil { |
| 65 | ConsoleLog.WithError(err).Error("start adapter failed") |
| 66 | SetExitStatus(1) |
| 67 | return nil |
| 68 | } |
| 69 | |
| 70 | ConsoleLog.Infof("adapter started on %s", adapterAddr) |
| 71 | |
| 72 | return func() { |
| 73 | ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) |
| 74 | defer cancel() |
| 75 | adapterHTTPServer.Shutdown(ctx) |
| 76 | ConsoleLog.Info("adapter stopped") |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | func runAdapter(cmd *Command, args []string) { |
| 81 | commonFlagsInit(cmd) |
no test coverage detected