mirror of
https://github.com/go-acme/lego
synced 2024-05-08 22:16:33 +02:00
exec: stream command output (#2166)
This commit is contained in:
parent
76eb1eac8a
commit
42aa57e2b9
|
@ -2,6 +2,7 @@
|
|||
package exec
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
@ -117,10 +118,27 @@ func (d *DNSProvider) run(ctx context.Context, command, domain, token, keyAuth s
|
|||
|
||||
cmd := exec.CommandContext(ctx, d.config.Program, args...)
|
||||
|
||||
output, err := cmd.CombinedOutput()
|
||||
if len(output) > 0 {
|
||||
log.Println(string(output))
|
||||
stdout, err := cmd.StdoutPipe()
|
||||
if err != nil {
|
||||
return fmt.Errorf("create pipe: %w", err)
|
||||
}
|
||||
|
||||
return err
|
||||
cmd.Stderr = cmd.Stdout
|
||||
|
||||
err = cmd.Start()
|
||||
if err != nil {
|
||||
return fmt.Errorf("start command: %w", err)
|
||||
}
|
||||
|
||||
scanner := bufio.NewScanner(stdout)
|
||||
for scanner.Scan() {
|
||||
log.Println(scanner.Text())
|
||||
}
|
||||
|
||||
err = cmd.Wait()
|
||||
if err != nil {
|
||||
return fmt.Errorf("wait command: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue