2022-07-17 18:16:00 +00:00
|
|
|
// Copyright (C) 2019-2022 Nicola Murino
|
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Affero General Public License as published
|
|
|
|
// by the Free Software Foundation, version 3.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
2020-02-02 21:20:39 +00:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2020-06-20 12:30:46 +00:00
|
|
|
"os"
|
2020-02-02 21:20:39 +00:00
|
|
|
|
|
|
|
"github.com/spf13/cobra"
|
2020-05-06 17:36:34 +00:00
|
|
|
|
2021-06-26 05:31:41 +00:00
|
|
|
"github.com/drakkan/sftpgo/v2/service"
|
2020-02-02 21:20:39 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
reloadCmd = &cobra.Command{
|
|
|
|
Use: "reload",
|
|
|
|
Short: "Reload the SFTPGo Windows Service sending a \"paramchange\" request",
|
|
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
|
|
s := service.WindowsService{
|
|
|
|
Service: service.Service{
|
|
|
|
Shutdown: make(chan bool),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
err := s.Reload()
|
|
|
|
if err != nil {
|
2020-06-22 17:11:53 +00:00
|
|
|
fmt.Printf("Error sending reload signal: %v\r\n", err)
|
2020-06-20 12:30:46 +00:00
|
|
|
os.Exit(1)
|
2020-02-02 21:20:39 +00:00
|
|
|
} else {
|
2020-06-22 17:11:53 +00:00
|
|
|
fmt.Printf("Reload signal sent!\r\n")
|
2020-02-02 21:20:39 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
serviceCmd.AddCommand(reloadCmd)
|
|
|
|
}
|