mirror of
https://github.com/drakkan/sftpgo.git
synced 2024-11-22 07:30:25 +00:00
bb5207ad77
Fixes #161
53 lines
1.2 KiB
Go
53 lines
1.2 KiB
Go
package cmd
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/drakkan/sftpgo/service"
|
|
"github.com/drakkan/sftpgo/utils"
|
|
)
|
|
|
|
var (
|
|
serveCmd = &cobra.Command{
|
|
Use: "serve",
|
|
Short: "Start the SFTP Server",
|
|
Long: `To start the SFTPGo with the default values for the command line flags simply
|
|
use:
|
|
|
|
$ sftpgo serve
|
|
|
|
Please take a look at the usage below to customize the startup options`,
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
service := service.Service{
|
|
ConfigDir: utils.CleanDirInput(configDir),
|
|
ConfigFile: configFile,
|
|
LogFilePath: logFilePath,
|
|
LogMaxSize: logMaxSize,
|
|
LogMaxBackups: logMaxBackups,
|
|
LogMaxAge: logMaxAge,
|
|
LogCompress: logCompress,
|
|
LogVerbose: logVerbose,
|
|
LoadDataFrom: loadDataFrom,
|
|
LoadDataMode: loadDataMode,
|
|
LoadDataQuotaScan: loadDataQuotaScan,
|
|
LoadDataClean: loadDataClean,
|
|
Profiler: profiler,
|
|
Shutdown: make(chan bool),
|
|
}
|
|
if err := service.Start(); err == nil {
|
|
service.Wait()
|
|
if service.Error == nil {
|
|
os.Exit(0)
|
|
}
|
|
}
|
|
os.Exit(1)
|
|
},
|
|
}
|
|
)
|
|
|
|
func init() {
|
|
rootCmd.AddCommand(serveCmd)
|
|
addServeFlags(serveCmd)
|
|
}
|