42 lines
770 B
Go
42 lines
770 B
Go
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)
|
|
}
|
|
|
|
}
|