volcano.sh/volcano@v1.9.0/cmd/cli/vresume/main.go (about)

     1  /*
     2  Copyright 2019 The Volcano Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8  	http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  package main
    17  
    18  import (
    19  	"fmt"
    20  	"os"
    21  	"time"
    22  
    23  	"github.com/spf13/cobra"
    24  	"github.com/spf13/pflag"
    25  
    26  	"k8s.io/apimachinery/pkg/util/wait"
    27  	"k8s.io/klog/v2"
    28  
    29  	"volcano.sh/volcano/cmd/cli/util"
    30  	"volcano.sh/volcano/pkg/cli/vresume"
    31  )
    32  
    33  var logFlushFreq = pflag.Duration("log-flush-frequency", 5*time.Second, "Maximum number of seconds between log flushes")
    34  
    35  func main() {
    36  	// flag.InitFlags()
    37  	klog.InitFlags(nil)
    38  
    39  	// The default klog flush interval is 30 seconds, which is frighteningly long.
    40  	go wait.Until(klog.Flush, *logFlushFreq, wait.NeverStop)
    41  	defer klog.Flush()
    42  
    43  	rootCmd := cobra.Command{
    44  		Use:   "vresume",
    45  		Short: "resume a job",
    46  		Long:  `resume an aborted job with specified name in default or specified namespace`,
    47  		Run: func(cmd *cobra.Command, args []string) {
    48  			util.CheckError(cmd, vresume.ResumeJob())
    49  		},
    50  	}
    51  
    52  	jobResumeCmd := &rootCmd
    53  	vresume.InitResumeFlags(jobResumeCmd)
    54  	if err := rootCmd.Execute(); err != nil {
    55  		fmt.Printf("Failed to execute vresume: %v\n", err)
    56  		os.Exit(-2)
    57  	}
    58  }