Select Git revision
-
Johan de Klerk authoredJohan de Klerk authored
debug.go 3.20 KiB
package mage_helpers
import (
"context"
"fmt"
"log"
"os"
"os/exec"
"os/signal"
"os/user"
"strings"
"syscall"
"github.com/docker/docker/api/types"
"github.com/docker/docker/client"
)
func SamStartApi(ctx context.Context, handler string, profile string, debug bool) error {
stopRunningSamDocker()
usr, _ := user.Current()
homeDir := usr.HomeDir
delveDir := homeDir + "/go/delve/"
commandArgs := []string{
`local`,
`start-api`,
}
if debug {
commandArgs = append(commandArgs, `--debug-port=5986`,
fmt.Sprintf(`--debugger-path=%s`, delveDir),
`--debug-args=-delveAPI=2`)
}
commandArgs = append(commandArgs,
fmt.Sprintf(`--profile=%v`, profile),
fmt.Sprintf(`--template=core/%v/template.yml`, handler),
`--region=af-south-1`)
err := runLongRunningSubProcess(ctx, "sam", commandArgs...)
if err != nil {
return err
}
return nil
}
func SamInvokeSQS(ctx context.Context, handler string, function string, profile string) error {
stopRunningSamDocker()
usr, _ := user.Current()
homeDir := usr.HomeDir
delveDir := homeDir + "/go/delve/"
commandArgs := []string{
`local`,
`invoke`,
`-e`,
fmt.Sprintf(`core/%v/sqs.input.json`, handler),
function,
`--debug-port=5986`,
fmt.Sprintf(`--debugger-path=%s`, delveDir),
`--debug-args=-delveAPI=2`,
fmt.Sprintf(`--profile=%v`, profile),
fmt.Sprintf(`--template=core/%v/template.yml`, handler),
`--region=af-south-1`,
}
err := runLongRunningSubProcess(ctx, "sam", commandArgs...)