TUN-5933: Better messaging to help user when installing service if it is already installed
This commit is contained in:
parent
98736a03e1
commit
62e1330e45
|
@ -44,7 +44,7 @@ func (st *ServiceTemplate) Generate(args *ServiceTemplateArgs) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if _, err = os.Stat(resolvedPath); err == nil {
|
if _, err = os.Stat(resolvedPath); err == nil {
|
||||||
return fmt.Errorf("cloudflared service is already installed at %s", resolvedPath)
|
return fmt.Errorf(serviceAlreadyExistsWarn(resolvedPath))
|
||||||
}
|
}
|
||||||
|
|
||||||
var buffer bytes.Buffer
|
var buffer bytes.Buffer
|
||||||
|
@ -75,6 +75,15 @@ func (st *ServiceTemplate) Remove() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func serviceAlreadyExistsWarn(service string) string {
|
||||||
|
return fmt.Sprintf("cloudflared service is already installed at %s; if you are running a cloudflared tunnel, you "+
|
||||||
|
"can point it to multiple origins, avoiding the need to run more than one cloudflared service in the "+
|
||||||
|
"same machine; otherwise if you are really sure, you can do `cloudflared service uninstall` to clean "+
|
||||||
|
"up the existing service and then try again this command",
|
||||||
|
service,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
func runCommand(command string, args ...string) error {
|
func runCommand(command string, args ...string) error {
|
||||||
cmd := exec.Command(command, args...)
|
cmd := exec.Command(command, args...)
|
||||||
stderr, err := cmd.StderrPipe()
|
stderr, err := cmd.StderrPipe()
|
||||||
|
|
|
@ -191,7 +191,7 @@ func installWindowsService(c *cli.Context) error {
|
||||||
log := zeroLogger.With().Str(LogFieldWindowsServiceName, windowsServiceName).Logger()
|
log := zeroLogger.With().Str(LogFieldWindowsServiceName, windowsServiceName).Logger()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
s.Close()
|
s.Close()
|
||||||
return fmt.Errorf("Service %s already exists", windowsServiceName)
|
return fmt.Errorf(serviceAlreadyExistsWarn(windowsServiceName))
|
||||||
}
|
}
|
||||||
extraArgs, err := getServiceExtraArgsFromCliArgs(c, &log)
|
extraArgs, err := getServiceExtraArgsFromCliArgs(c, &log)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue