reload_windows.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Copyright (C) 2019-2023 Nicola Murino
  2. //
  3. // This program is free software: you can redistribute it and/or modify
  4. // it under the terms of the GNU Affero General Public License as published
  5. // by the Free Software Foundation, version 3.
  6. //
  7. // This program is distributed in the hope that it will be useful,
  8. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. // GNU Affero General Public License for more details.
  11. //
  12. // You should have received a copy of the GNU Affero General Public License
  13. // along with this program. If not, see <https://www.gnu.org/licenses/>.
  14. package cmd
  15. import (
  16. "fmt"
  17. "os"
  18. "github.com/spf13/cobra"
  19. "github.com/drakkan/sftpgo/v2/internal/service"
  20. )
  21. var (
  22. reloadCmd = &cobra.Command{
  23. Use: "reload",
  24. Short: "Reload the SFTPGo Windows Service sending a \"paramchange\" request",
  25. Run: func(_ *cobra.Command, _ []string) {
  26. s := service.WindowsService{
  27. Service: service.Service{
  28. Shutdown: make(chan bool),
  29. },
  30. }
  31. err := s.Reload()
  32. if err != nil {
  33. fmt.Printf("Error sending reload signal: %v\r\n", err)
  34. os.Exit(1)
  35. } else {
  36. fmt.Printf("Reload signal sent!\r\n")
  37. }
  38. },
  39. }
  40. )
  41. func init() {
  42. serviceCmd.AddCommand(reloadCmd)
  43. }