1
0

serve.go 931 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package cmd
  2. import (
  3. "github.com/drakkan/sftpgo/service"
  4. "github.com/drakkan/sftpgo/utils"
  5. "github.com/spf13/cobra"
  6. )
  7. var (
  8. serveCmd = &cobra.Command{
  9. Use: "serve",
  10. Short: "Start the SFTP Server",
  11. Long: `To start the SFTPGo with the default values for the command line flags simply use:
  12. sftpgo serve
  13. Please take a look at the usage below to customize the startup options`,
  14. Run: func(cmd *cobra.Command, args []string) {
  15. service := service.Service{
  16. ConfigDir: utils.CleanDirInput(configDir),
  17. ConfigFile: configFile,
  18. LogFilePath: logFilePath,
  19. LogMaxSize: logMaxSize,
  20. LogMaxBackups: logMaxBackups,
  21. LogMaxAge: logMaxAge,
  22. LogCompress: logCompress,
  23. LogVerbose: logVerbose,
  24. Shutdown: make(chan bool),
  25. }
  26. if err := service.Start(); err == nil {
  27. service.Wait()
  28. }
  29. },
  30. }
  31. )
  32. func init() {
  33. rootCmd.AddCommand(serveCmd)
  34. addServeFlags(serveCmd)
  35. }