fix: allow just binary execution

This commit is contained in:
Urko. 2024-05-24 22:25:36 +02:00
parent adf47e4810
commit 9c735ccf64
2 changed files with 6 additions and 5 deletions

View File

@ -13,8 +13,8 @@ type Config struct {
}
type ConfigScript struct {
Environment string `yaml:"environment"`
BinaryPath string `yaml:"binary"`
ScriptPath string `yaml:"script"`
Command string `yaml:"command"`
Arguments string `yaml:"args"`
}
func LoadConfig(path string) (*Config, error) {

View File

@ -27,6 +27,7 @@ func main() {
if err != nil {
log.Fatalf("Error loading config: %v", err)
}
log.Println("GOOO")
http.HandleFunc("/", handlePayload(cfg.Secret, cfg.Projects))
http.ListenAndServe(fmt.Sprintf(":%d", cfg.Port), nil)
}
@ -80,15 +81,15 @@ func handlePayload(secret string, projects map[string][]config.ConfigScript) fun
}
go func() {
if err := execute(scr.BinaryPath, scr.ScriptPath); err != nil {
if err := execute(scr.Command, scr.Arguments); err != nil {
log.Println(err)
}
}()
})
}
func execute(binaryPath, scriptPath string) error {
cmd := exec.Command(binaryPath, scriptPath)
func execute(command, args string) error {
cmd := exec.Command(command, args)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr