Execing command instead of waiting
This commit is contained in:
parent
eb00c9e9e4
commit
e66547d0a1
@ -33,8 +33,5 @@ func main() {
|
||||
logger.Error.Printf("COMMAND env is empty")
|
||||
os.Exit(1)
|
||||
}
|
||||
if err = comm.ExecuteCommand(command); err != nil {
|
||||
logger.Error.Printf("Executing command failed: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
comm.ExecuteCommand(command)
|
||||
}
|
||||
|
@ -3,24 +3,23 @@ package command
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"syscall"
|
||||
|
||||
"github.com/stackanetes/kubernetes-entrypoint/logger"
|
||||
)
|
||||
|
||||
func ExecuteCommand(command []string) error {
|
||||
func ExecuteCommand(command []string) {
|
||||
path, err := exec.LookPath(command[0])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
cmd := exec.Cmd{
|
||||
Path: path,
|
||||
Args: command,
|
||||
Stdout: os.Stdout,
|
||||
Stderr: os.Stderr,
|
||||
logger.Error.Printf("Cannot find a binary %v : %v", command[0], err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
err = cmd.Start()
|
||||
env := os.Environ()
|
||||
err = syscall.Exec(path, command, env)
|
||||
if err != nil {
|
||||
return err
|
||||
logger.Error.Print("Executing command %v failed: %v", command, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user