fix frps service init

This commit is contained in:
马嘉聪 2019-05-11 16:54:36 +08:00
parent 3cb1dddb45
commit cd0959bba0
2 changed files with 11 additions and 7 deletions

View File

@ -97,7 +97,17 @@ var rootCmd = &cobra.Command{
} }
if !service.Interactive() { if !service.Interactive() {
if err := srvCmd.Execute(); err != nil { var err error
srv, err = service.New(&serviceFRP{}, &service.Config{
Name: srvName,
DisplayName: srvDName,
Description: srvDesc,
})
if err != nil {
fmt.Println(err)
os.Exit(1)
}
if err = srv.Run(); err != nil {
fmt.Println(err) fmt.Println(err)
os.Exit(1) os.Exit(1)
} }

View File

@ -38,12 +38,6 @@ func init() {
rootCmd.PersistentFlags().StringVar(&srvDName, "display_name", "frps", "Service display name") rootCmd.PersistentFlags().StringVar(&srvDName, "display_name", "frps", "Service display name")
rootCmd.PersistentFlags().StringVar(&srvDesc, "description", "frps service", "Service description") rootCmd.PersistentFlags().StringVar(&srvDesc, "description", "frps service", "Service description")
if !service.Interactive() {
srvCmd.RunE = func(cmd *cobra.Command, args []string) error {
return srv.Run()
}
}
srvCmd.AddCommand(installSrvCmd, uninstallSrvCmd, startSrvCmd, stopSrvCmd, restartSrvCmd) srvCmd.AddCommand(installSrvCmd, uninstallSrvCmd, startSrvCmd, stopSrvCmd, restartSrvCmd)
rootCmd.AddCommand(srvCmd) rootCmd.AddCommand(srvCmd)
} }