fix: allow just binary execution
This commit is contained in:
parent
adf47e4810
commit
9c735ccf64
|
@ -13,8 +13,8 @@ type Config struct {
|
||||||
}
|
}
|
||||||
type ConfigScript struct {
|
type ConfigScript struct {
|
||||||
Environment string `yaml:"environment"`
|
Environment string `yaml:"environment"`
|
||||||
BinaryPath string `yaml:"binary"`
|
Command string `yaml:"command"`
|
||||||
ScriptPath string `yaml:"script"`
|
Arguments string `yaml:"args"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func LoadConfig(path string) (*Config, error) {
|
func LoadConfig(path string) (*Config, error) {
|
||||||
|
|
7
main.go
7
main.go
|
@ -27,6 +27,7 @@ func main() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Error loading config: %v", err)
|
log.Fatalf("Error loading config: %v", err)
|
||||||
}
|
}
|
||||||
|
log.Println("GOOO")
|
||||||
http.HandleFunc("/", handlePayload(cfg.Secret, cfg.Projects))
|
http.HandleFunc("/", handlePayload(cfg.Secret, cfg.Projects))
|
||||||
http.ListenAndServe(fmt.Sprintf(":%d", cfg.Port), nil)
|
http.ListenAndServe(fmt.Sprintf(":%d", cfg.Port), nil)
|
||||||
}
|
}
|
||||||
|
@ -80,15 +81,15 @@ func handlePayload(secret string, projects map[string][]config.ConfigScript) fun
|
||||||
}
|
}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
if err := execute(scr.BinaryPath, scr.ScriptPath); err != nil {
|
if err := execute(scr.Command, scr.Arguments); err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func execute(binaryPath, scriptPath string) error {
|
func execute(command, args string) error {
|
||||||
cmd := exec.Command(binaryPath, scriptPath)
|
cmd := exec.Command(command, args)
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue