file_monitoring/main.go

42 lines
770 B
Go
Raw Normal View History

2022-08-07 20:49:02 +08:00
package main
import (
"file_monitoring/cmd"
"file_monitoring/config"
"fmt"
"net/http"
"os"
"github.com/spf13/cobra"
)
var (
rootCmd = &cobra.Command{
Use: "file_monitoring",
Long: "file_monitoring is a file monitoring and transfer tool",
Version: config.Version,
}
enablePprof bool
pprofAddr = "127.0.0.1:6060"
)
func init() {
config.DefaultConfig()
rootCmd.PersistentFlags().StringVarP(&cmd.ConfigFile, "config", "c", cmd.ConfigFile, "The configuration file path")
rootCmd.AddCommand(cmd.Run())
//rootCmd.AddCommand(cmd.NewReloadCommand())
}
func main() {
if enablePprof {
go func() {
http.ListenAndServe(pprofAddr, nil)
}()
}
if err := rootCmd.Execute(); err != nil {
fmt.Fprint(os.Stderr, err.Error())
os.Exit(1)
}
}