serve.go 960 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. Profiler: profiler,
  25. Shutdown: make(chan bool),
  26. }
  27. if err := service.Start(); err == nil {
  28. service.Wait()
  29. }
  30. },
  31. }
  32. )
  33. func init() {
  34. rootCmd.AddCommand(serveCmd)
  35. addServeFlags(serveCmd)
  36. }