stop_windows.go 548 B

1234567891011121314151617181920212223242526272829303132
  1. package cmd
  2. import (
  3. "fmt"
  4. "github.com/drakkan/sftpgo/service"
  5. "github.com/spf13/cobra"
  6. )
  7. var (
  8. stopCmd = &cobra.Command{
  9. Use: "stop",
  10. Short: "Stop SFTPGo Windows Service",
  11. Run: func(cmd *cobra.Command, args []string) {
  12. s := service.WindowsService{
  13. Service: service.Service{
  14. Shutdown: make(chan bool),
  15. },
  16. }
  17. err := s.Stop()
  18. if err != nil {
  19. fmt.Printf("Error stopping service: %v\r\n", err)
  20. } else {
  21. fmt.Printf("Service stopped!\r\n")
  22. }
  23. },
  24. }
  25. )
  26. func init() {
  27. serviceCmd.AddCommand(stopCmd)
  28. }