updated run flag to create new profile each time
This commit is contained in:
parent
504fc59573
commit
a21ff16308
1 changed files with 21 additions and 3 deletions
|
@ -6,6 +6,7 @@ import (
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Array to store errors
|
// Array to store errors
|
||||||
|
@ -243,15 +244,32 @@ func RunProject(sourcePath string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run the binary
|
// Create a unique profile directory for each run
|
||||||
cmd := exec.Command(binaryPath)
|
profilePath := filepath.Join(buildDir, fmt.Sprintf("profile_%d", time.Now().UnixNano()))
|
||||||
|
if err := os.Mkdir(profilePath, 0755); err != nil {
|
||||||
|
fmt.Printf("Failed to create profile directory: %v\n", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run the binary with the new profile
|
||||||
|
cmd := exec.Command(binaryPath, "-no-remote", "-profile", profilePath)
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
cmd.Stdin = os.Stdin
|
cmd.Stdin = os.Stdin
|
||||||
|
|
||||||
fmt.Printf("Running binary: %s\n", binaryPath)
|
fmt.Printf("Running binary: %s with new profile at %s\n", binaryPath, profilePath)
|
||||||
if err := cmd.Run(); err != nil {
|
if err := cmd.Run(); err != nil {
|
||||||
fmt.Printf("Failed to run the project: %v\n", err)
|
fmt.Printf("Failed to run the project: %v\n", err)
|
||||||
|
} else {
|
||||||
|
fmt.Println("Binary execution finished successfully.")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete the profile directory after execution
|
||||||
|
fmt.Printf("Deleting profile directory: %s\n", profilePath)
|
||||||
|
if err := os.RemoveAll(profilePath); err != nil {
|
||||||
|
fmt.Printf("Failed to delete profile directory: %v\n", err)
|
||||||
|
} else {
|
||||||
|
fmt.Println("Profile directory deleted successfully.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue