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

Function SetupJobManager

pkg/jobmanager/jobmanager.go:48–94  ·  view source on GitHub ↗
(clientId string, jobId string, publicKeyBytes []byte, jobAuthToken string, readyFile *os.File)

Source from the content-addressed store, hash-verified

46}
47
48func SetupJobManager(clientId string, jobId string, publicKeyBytes []byte, jobAuthToken string, readyFile *os.File) error {
49 if runtime.GOOS != "linux" && runtime.GOOS != "darwin" {
50 return fmt.Errorf("job manager only supported on unix systems, not %s", runtime.GOOS)
51 }
52 WshCmdJobManager.ClientId = clientId
53 WshCmdJobManager.JobId = jobId
54 WshCmdJobManager.JwtPublicKey = publicKeyBytes
55 WshCmdJobManager.JobAuthToken = jobAuthToken
56 WshCmdJobManager.StreamManager = MakeStreamManager()
57 WshCmdJobManager.InputQueue = utilds.MakeQuickReorderQueue[wshrpc.CommandJobInputData](JobInputQueueSize, JobInputQueueTimeout)
58 err := wavejwt.SetPublicKey(publicKeyBytes)
59 if err != nil {
60 return fmt.Errorf("failed to set public key: %w", err)
61 }
62 err = MakeJobDomainSocket(clientId, jobId)
63 if err != nil {
64 return err
65 }
66
67 go func() {
68 defer func() {
69 panichandler.PanicHandler("JobManager:processInputQueue", recover())
70 }()
71 WshCmdJobManager.processInputQueue()
72 }()
73
74 fmt.Fprintf(readyFile, JobManagerStartLabel+"\n")
75 readyFile.Close()
76
77 err = daemonize(clientId, jobId)
78 if err != nil {
79 return fmt.Errorf("failed to daemonize: %w", err)
80 }
81
82 go func() {
83 defer func() {
84 panichandler.PanicHandler("JobManager:keepalive", recover())
85 }()
86 ticker := time.NewTicker(1 * time.Hour)
87 defer ticker.Stop()
88 for range ticker.C {
89 log.Printf("keepalive: job manager active\n")
90 }
91 }()
92
93 return nil
94}
95
96func (jm *JobManager) processInputQueue() {
97 for data := range jm.InputQueue.C() {

Callers 1

jobManagerRunFunction · 0.92

Calls 9

MakeQuickReorderQueueFunction · 0.92
SetPublicKeyFunction · 0.92
PanicHandlerFunction · 0.92
MakeStreamManagerFunction · 0.85
MakeJobDomainSocketFunction · 0.85
processInputQueueMethod · 0.80
daemonizeFunction · 0.70
CloseMethod · 0.65
StopMethod · 0.65

Tested by

no test coverage detected