(clientId string, jobId string)
| 377 | } |
| 378 | |
| 379 | func MakeJobDomainSocket(clientId string, jobId string) error { |
| 380 | socketDir := filepath.Join("/tmp", fmt.Sprintf("waveterm-%d", os.Getuid())) |
| 381 | err := os.MkdirAll(socketDir, 0700) |
| 382 | if err != nil { |
| 383 | return fmt.Errorf("failed to create socket directory: %w", err) |
| 384 | } |
| 385 | |
| 386 | socketPath := wavebase.GetRemoteJobSocketPath(jobId) |
| 387 | |
| 388 | os.Remove(socketPath) |
| 389 | |
| 390 | listener, err := net.Listen("unix", socketPath) |
| 391 | if err != nil { |
| 392 | return fmt.Errorf("failed to listen on domain socket: %w", err) |
| 393 | } |
| 394 | |
| 395 | go func() { |
| 396 | defer func() { |
| 397 | panichandler.PanicHandler("MakeJobDomainSocket:accept", recover()) |
| 398 | listener.Close() |
| 399 | os.Remove(socketPath) |
| 400 | }() |
| 401 | for { |
| 402 | conn, err := listener.Accept() |
| 403 | if err != nil { |
| 404 | log.Printf("error accepting connection: %v\n", err) |
| 405 | return |
| 406 | } |
| 407 | go handleJobDomainSocketClient(conn) |
| 408 | } |
| 409 | }() |
| 410 | |
| 411 | return nil |
| 412 | } |
| 413 | |
| 414 | func handleJobDomainSocketClient(conn net.Conn) { |
| 415 | inputCh := make(chan baseds.RpcInputChType, wshutil.DefaultInputChSize) |
no test coverage detected