This repository was archived by the owner on Apr 4, 2023. It is now read-only.
  
  
  
  
    
    
    
      
    
  
  
    
File tree Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -14,8 +14,6 @@ func (p *Pilot) CmdFunc(pilot *v1alpha1.Pilot) (*exec.Cmd, error) {
1414	}
1515
1616	cmd  :=  exec .Command ("elasticsearch" )
17- 	cmd .Stdout  =  os .Stdout 
18- 	cmd .Stderr  =  os .Stderr 
1917	cmd .Env  =  p .env ().Strings ()
2018
2119	return  cmd , nil 
Original file line number Diff line number Diff line change 11package  process
22
33import  (
4+ 	"bufio" 
45	"fmt" 
56	"os" 
67	"os/exec" 
8+ 	"sync" 
79
810	"github.com/golang/glog" 
911)
@@ -33,12 +35,37 @@ type Interface interface {
3335type  Adapter  struct  {
3436	Signals  Signals 
3537	Cmd      * exec.Cmd 
38+ 	wg       sync.WaitGroup 
3639}
3740
3841var  _  Interface  =  & Adapter {}
3942
4043func  (p  * Adapter ) Start () error  {
4144	glog .V (2 ).Infof ("Starting process: %v" , p .Cmd .Args )
45+ 	stdout , err  :=  p .Cmd .StdoutPipe ()
46+ 	if  err  !=  nil  {
47+ 		return  err 
48+ 	}
49+ 	p .wg .Add (1 )
50+ 	go  func () {
51+ 		in  :=  bufio .NewScanner (stdout )
52+ 		for  in .Scan () {
53+ 			glog .Info (in .Text ())
54+ 		}
55+ 		p .wg .Done ()
56+ 	}()
57+ 	stderr , err  :=  p .Cmd .StderrPipe ()
58+ 	if  err  !=  nil  {
59+ 		return  err 
60+ 	}
61+ 	p .wg .Add (1 )
62+ 	go  func () {
63+ 		in  :=  bufio .NewScanner (stderr )
64+ 		for  in .Scan () {
65+ 			glog .Error (in .Text ())
66+ 		}
67+ 		p .wg .Done ()
68+ 	}()
4269
4370	if  err  :=  p .Cmd .Start (); err  !=  nil  {
4471		return  fmt .Errorf ("error starting process: %s" , err .Error ())
@@ -47,6 +74,7 @@ func (p *Adapter) Start() error {
4774}
4875
4976func  (p  * Adapter ) Wait () error  {
77+ 	defer  p .wg .Wait ()
5078	return  p .Cmd .Wait ()
5179}
5280
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments