in cmd/nfsplugin/main.go [52:90]
func main() {
klog.InitFlags(nil)
_ = flag.Set("logtostderr", "true")
flag.Parse()
if *nodeID == "" {
klog.Warning("nodeid is empty")
}
klog.V(4).Infof("runController %v, runNodeServer %v, runNfsServices %v", *runControllerServer, *runNodeServer, *runNfsServices)
ctx, cancel := context.WithCancel(context.Background())
if *runNfsServices && !*runControllerServer {
// Start the NFS services in the background
cmd := exec.CommandContext(ctx, NfsServicesStartCmd)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Cancel = func() error {
klog.V(4).Infof("sending SIGTERM to nfs process: %v", cmd)
return cmd.Process.Signal(syscall.SIGTERM)
}
if err := cmd.Start(); err != nil {
klog.Fatalf("Error starting nfs services: %v", err)
return
}
klog.V(2).Infof("nfs services started in the background with PID: %d", cmd.Process.Pid)
}
go handle()
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGTERM)
klog.Info("waiting for SIGTERM signal...")
<-c // blocking the process
klog.Info("received SIGTERM signal, calling cancel")
cancel()
os.Exit(0)
}