Keep run logs opaque and streamline transfers
This commit is contained in:
@@ -52,17 +52,36 @@ type windowsFileManagedProcess struct {
|
||||
}
|
||||
|
||||
type managedProcessHelperSpec struct {
|
||||
Command ProcessCommand `json:"command"`
|
||||
StopEventName string `json:"stopEventName,omitempty"`
|
||||
StdoutPath string `json:"stdoutPath,omitempty"`
|
||||
StderrPath string `json:"stderrPath,omitempty"`
|
||||
PIDPath string `json:"pidPath,omitempty"`
|
||||
Command managedProcessHelperCommand `json:"command"`
|
||||
StopEventName string `json:"stopEventName,omitempty"`
|
||||
StdoutPath string `json:"stdoutPath,omitempty"`
|
||||
StderrPath string `json:"stderrPath,omitempty"`
|
||||
PIDPath string `json:"pidPath,omitempty"`
|
||||
}
|
||||
|
||||
type managedProcessHelperCommand struct {
|
||||
WorkDir string `json:"workDir,omitempty"`
|
||||
Args []string `json:"args,omitempty"`
|
||||
Env map[string]string `json:"env,omitempty"`
|
||||
OutputMode string `json:"outputMode,omitempty"`
|
||||
Timeout time.Duration `json:"timeout,omitempty"`
|
||||
JobID string `json:"jobId,omitempty"`
|
||||
Capability string `json:"capability,omitempty"`
|
||||
Action string `json:"action,omitempty"`
|
||||
}
|
||||
|
||||
func managedProcessHelperCommandFromProcess(command ProcessCommand) managedProcessHelperCommand {
|
||||
return managedProcessHelperCommand{WorkDir: command.WorkDir, Args: append([]string(nil), command.Args...), Env: copyStringMap(command.Env), OutputMode: command.OutputMode, Timeout: command.Timeout, JobID: command.JobID, Capability: command.Capability, Action: command.Action}
|
||||
}
|
||||
|
||||
func (command managedProcessHelperCommand) processCommand() ProcessCommand {
|
||||
return ProcessCommand{WorkDir: command.WorkDir, Args: append([]string(nil), command.Args...), Env: copyStringMap(command.Env), OutputMode: command.OutputMode, Timeout: command.Timeout, JobID: command.JobID, Capability: command.Capability, Action: command.Action}
|
||||
}
|
||||
|
||||
func startManagedProcess(command ProcessCommand, files managedProcessFiles, stopEventName string) (managedProcess, error) {
|
||||
pidPath := files.stdout.Name() + ".pid"
|
||||
_ = os.Remove(pidPath)
|
||||
body, err := json.Marshal(managedProcessHelperSpec{Command: command, StopEventName: stopEventName, StdoutPath: files.stdout.Name(), StderrPath: files.stderr.Name(), PIDPath: pidPath})
|
||||
body, err := json.Marshal(managedProcessHelperSpec{Command: managedProcessHelperCommandFromProcess(command), StopEventName: stopEventName, StdoutPath: files.stdout.Name(), StderrPath: files.stderr.Name(), PIDPath: pidPath})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("encode managed process helper spec: %w", err)
|
||||
}
|
||||
@@ -189,7 +208,7 @@ func runManagedProcessHelper(spec managedProcessHelperSpec) (int, error) {
|
||||
return 1, fmt.Errorf("open managed process stderr: %w", err)
|
||||
}
|
||||
defer closeStderr()
|
||||
command := spec.Command
|
||||
command := spec.Command.processCommand()
|
||||
stopEventName := spec.StopEventName
|
||||
// The plugin-declared pipes mode uses ordinary inherited handles. The
|
||||
// durable output files are attached directly to the child process, so this
|
||||
|
||||
Reference in New Issue
Block a user