Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7f44e5ed41 | |||
| bcc53dfbe0 |
@@ -56,6 +56,12 @@ func (s *ApiServer) GetRunnerFromMap(u uuid.UUID) (*RunnerWrapper, bool) {
|
||||
return runner, ok
|
||||
}
|
||||
|
||||
func (s *ApiServer) AddRunnerToMap(u uuid.UUID, runner *runnermanager.Runner) {
|
||||
s.allocatedRunnersMutex.Lock()
|
||||
defer s.allocatedRunnersMutex.Unlock()
|
||||
s.allocatedRunners[u] = &RunnerWrapper{runner: runner}
|
||||
}
|
||||
|
||||
func (s *ApiServer) GetRunner(
|
||||
ctx context.Context,
|
||||
req *connect.Request[apiv2.GetRunnerRequest],
|
||||
@@ -114,9 +120,7 @@ func (s *ApiServer) GetRunner(
|
||||
|
||||
runnerUuid := uuid.New()
|
||||
|
||||
s.allocatedRunnersMutex.Lock()
|
||||
s.allocatedRunners[runnerUuid] = &RunnerWrapper{runner: response.Runner}
|
||||
s.allocatedRunnersMutex.Unlock()
|
||||
s.AddRunnerToMap(runnerUuid, response.Runner)
|
||||
|
||||
res := connect.NewResponse(&apiv2.GetRunnerResponse{
|
||||
Id: runnerUuid.String(),
|
||||
|
||||
@@ -45,6 +45,10 @@ func (r *Runner) Id() uuid.UUID {
|
||||
|
||||
func (r *Runner) RunCommand(cmd string, args []string) (returnCode int64, stdout string, stderr string, err error) {
|
||||
|
||||
if r.conn == nil {
|
||||
return 0, "", "", fmt.Errorf("runner with id %v has nil conn, THIS IS A BUG", r.id)
|
||||
}
|
||||
|
||||
// Write RunCommand message to client
|
||||
serverToRunnerMsg := &runner_api.ServerToRunnerMsg{
|
||||
Msg: &runner_api.ServerToRunnerMsg_RunCommandMsg{
|
||||
|
||||
Reference in New Issue
Block a user