Start begins listening for connections on the Unix socket, and handles new connections in a separate goroutine. Incoming logs from connections are buffered until RunForwarder drains them.
()
| 75 | // connections in a separate goroutine. Incoming logs from connections are |
| 76 | // buffered until RunForwarder drains them. |
| 77 | func (s *Server) Start() error { |
| 78 | if err := os.Remove(s.socketPath); err != nil && !os.IsNotExist(err) { |
| 79 | return xerrors.Errorf("remove existing socket: %w", err) |
| 80 | } |
| 81 | |
| 82 | listener, err := net.Listen("unix", s.socketPath) |
| 83 | if err != nil { |
| 84 | return xerrors.Errorf("listen on socket: %w", err) |
| 85 | } |
| 86 | |
| 87 | s.listener = listener |
| 88 | ctx, cancel := context.WithCancel(context.Background()) |
| 89 | s.cancel = cancel |
| 90 | |
| 91 | s.wg.Add(1) |
| 92 | go s.acceptLoop(ctx) |
| 93 | |
| 94 | s.logger.Info(ctx, "boundary log proxy started", slog.F("socket_path", s.socketPath)) |
| 95 | return nil |
| 96 | } |
| 97 | |
| 98 | // RunForwarder drains the log buffer and forwards logs to coderd. |
| 99 | // It blocks until ctx is canceled. |