MCPcopy Index your code
hub / github.com/wavetermdev/waveterm / MakeJobDomainSocket

Function MakeJobDomainSocket

pkg/jobmanager/jobmanager.go:379–412  ·  view source on GitHub ↗
(clientId string, jobId string)

Source from the content-addressed store, hash-verified

377}
378
379func 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
414func handleJobDomainSocketClient(conn net.Conn) {
415 inputCh := make(chan baseds.RpcInputChType, wshutil.DefaultInputChSize)

Callers 1

SetupJobManagerFunction · 0.85

Calls 4

GetRemoteJobSocketPathFunction · 0.92
PanicHandlerFunction · 0.92
CloseMethod · 0.65

Tested by

no test coverage detected