Skip to content
Snippets Groups Projects
Select Git revision
  • 249a88a8fdec7c777d590420e4cd2f0f300b8982
  • main default protected
  • 1-mage-run-does-not-stop-containers
  • v0.26.0
  • v0.25.0
  • v0.24.0
  • v0.23.0
  • v0.22.0
  • v0.21.0
  • v0.20.0
  • v0.19.0
  • v0.18.0
  • v0.17.0
  • v0.16.0
  • v0.15.0
  • v0.14.0
  • v0.13.0
  • v0.12.0
  • v0.11.0
  • v0.10.0
  • v0.9.0
  • v0.8.0
  • v0.7.0
23 results

debug.go

Blame
  • 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...)