MCPcopy
hub / github.com/wavetermdev/waveterm / tryTerminateJobManager

Function tryTerminateJobManager

pkg/jobcontroller/jobcontroller.go:895–919  ·  view source on GitHub ↗
(ctx context.Context, jobId string)

Source from the content-addressed store, hash-verified

893}
894
895func tryTerminateJobManager(ctx context.Context, jobId string) {
896 job, err := wstore.DBMustGet[*waveobj.Job](ctx, jobId)
897 if err != nil {
898 log.Printf("[job:%s] error getting job for termination check: %v", jobId, err)
899 return
900 }
901
902 if job.JobManagerStatus != JobManagerStatus_Running {
903 return
904 }
905
906 cmdExited := job.CmdExitTs != 0
907
908 if !cmdExited || !job.StreamDone {
909 log.Printf("[job:%s] not ready for termination: exited=%v streamDone=%v", jobId, cmdExited, job.StreamDone)
910 return
911 }
912
913 log.Printf("[job:%s] both job cmd exited and stream finished, terminating job manager", jobId)
914
915 err = TerminateJobManager(ctx, jobId)
916 if err != nil {
917 log.Printf("[job:%s] error terminating job manager: %v", jobId, err)
918 }
919}
920
921func TerminateAndDetachJob(ctx context.Context, jobId string) {
922 err := TerminateJobManager(ctx, jobId)

Callers 3

runOutputLoopFunction · 0.85
HandleCmdJobExitedFunction · 0.85
restartStreamingFunction · 0.85

Calls 2

DBMustGetFunction · 0.92
TerminateJobManagerFunction · 0.85

Tested by

no test coverage detected