43 lines
		
	
	
		
			1003 B
		
	
	
	
		
			Go
		
	
	
	
			
		
		
	
	
			43 lines
		
	
	
		
			1003 B
		
	
	
	
		
			Go
		
	
	
	
package main
 | 
						|
 | 
						|
import (
 | 
						|
	"flag"
 | 
						|
	"log"
 | 
						|
	"os"
 | 
						|
	"os/signal"
 | 
						|
	"sync"
 | 
						|
	"syscall"
 | 
						|
 | 
						|
	"github.bus.zalan.do/acid/postgres-operator/operator"
 | 
						|
	"github.com/spf13/pflag"
 | 
						|
)
 | 
						|
 | 
						|
var options operator.Options
 | 
						|
 | 
						|
func init() {
 | 
						|
	pflag.StringVar(&options.KubeConfig, "kubeconfig", "", "Path to kubeconfig file with authorization and master location information.")
 | 
						|
}
 | 
						|
 | 
						|
func main() {
 | 
						|
	// Set logging output to standard console out
 | 
						|
	log.SetOutput(os.Stdout)
 | 
						|
 | 
						|
	pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
 | 
						|
	pflag.Parse()
 | 
						|
 | 
						|
	sigs := make(chan os.Signal, 1)
 | 
						|
	stop := make(chan struct{})
 | 
						|
	signal.Notify(sigs, os.Interrupt, syscall.SIGTERM) // Push signals into channel
 | 
						|
 | 
						|
	wg := &sync.WaitGroup{} // Goroutines can add themselves to this to be waited on
 | 
						|
 | 
						|
	spiloOperator := operator.New(options)
 | 
						|
	spiloOperator.Run(stop, wg)
 | 
						|
 | 
						|
	sig := <-sigs // Wait for signals (this hangs until a signal arrives)
 | 
						|
	log.Printf("Shutting down... %+v", sig)
 | 
						|
 | 
						|
	close(stop) // Tell goroutines to stop themselves
 | 
						|
	wg.Wait()   // Wait for all to be stopped
 | 
						|
}
 |