webcmd: allow setting custom WorkingDir for process
This commit is contained in:
parent
7dde122d9b
commit
68c25fa139
4
Task.go
4
Task.go
@ -41,7 +41,7 @@ func uuid() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// LaunchTask creates a new task from the given command parameters.
|
// LaunchTask creates a new task from the given command parameters.
|
||||||
func (this *App) LaunchTask(params []string) (taskRef string, err error) {
|
func (this *App) LaunchTask(workDir string, params []string) (taskRef string, err error) {
|
||||||
if len(params) == 0 {
|
if len(params) == 0 {
|
||||||
return "", errors.New("No parameters for task")
|
return "", errors.New("No parameters for task")
|
||||||
}
|
}
|
||||||
@ -60,6 +60,8 @@ func (this *App) LaunchTask(params []string) (taskRef string, err error) {
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmd.Dir = workDir
|
||||||
|
|
||||||
err = cmd.Start()
|
err = cmd.Start()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
@ -23,6 +23,7 @@ type InputParam struct {
|
|||||||
|
|
||||||
type CommandConfig struct {
|
type CommandConfig struct {
|
||||||
Title string
|
Title string
|
||||||
|
WorkingDir string // default empty-string: getcwd()
|
||||||
Execution []InputParam // TODO allow plain strings as a shorthand for PARAMTYPE_CONST
|
Execution []InputParam // TODO allow plain strings as a shorthand for PARAMTYPE_CONST
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ func (this *App) Action_NewTask(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create new command from supplied values
|
// Create new command from supplied values
|
||||||
taskRef, err := this.LaunchTask(params)
|
taskRef, err := this.LaunchTask(taskInfo.WorkingDir, params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fail(w, r, err.Error())
|
fail(w, r, err.Error())
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user