diff options
Diffstat (limited to 'debug.go')
-rw-r--r-- | debug.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/debug.go b/debug.go new file mode 100644 index 0000000..1fd1356 --- /dev/null +++ b/debug.go @@ -0,0 +1,31 @@ +package debos + +import ( + "fmt" + "log" + "os" +) + +/* +DebugShell function launches an interactive shell for +debug and problems investigation. +*/ +func DebugShell(context DebosContext) { + + if len(context.DebugShell) == 0 { + return + } + + pa := os.ProcAttr{ + Files: []*os.File{os.Stdin, os.Stdout, os.Stderr}, + Dir: context.Scratchdir, + } + + // Start an interactive shell for debug. + log.Printf(">>> Starting a debug shell") + if proc, err := os.StartProcess(context.DebugShell, []string{}, &pa); err != nil { + fmt.Printf("Failed: %s\n", err) + } else { + proc.Wait() + } +} |