Files
tele-recv/cmd/start.go
T

52 lines
1.2 KiB
Go
Raw Normal View History

2020-12-21 15:38:33 +08:00
/*
Copyright © 2020 NAME HERE <EMAIL ADDRESS>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cmd
import (
"github.com/spf13/cobra"
"go.uber.org/zap"
"it2000.com.cn/tele-recv/app"
2020-12-21 15:38:33 +08:00
)
// startCmd represents the start command
var startCmd = &cobra.Command{
Use: "start",
2020-12-22 12:07:30 +08:00
Short: "start telegram receive service",
Long: `open serial port
start a tcp server for processing`,
RunE: func(cmd *cobra.Command, args []string) error {
return start()
2020-12-22 10:57:45 +08:00
},
2020-12-21 15:38:33 +08:00
}
func init() {
rootCmd.AddCommand(startCmd)
}
func start() error {
if appCfg == nil {
logger.Fatal("configuration not loaded")
2021-02-01 15:35:13 +08:00
}
2020-12-21 15:38:33 +08:00
a, err := app.New(appCfg)
if err != nil {
logger.Fatal("failed to create app", zap.Error(err))
}
return a.Run()
2020-12-21 15:38:33 +08:00
}