feat: execute durable client commands through supervisor
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
//go:build windows
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/rvbox/rvbox/internal/client/windowsservice"
|
||||
"golang.org/x/sys/windows/svc"
|
||||
)
|
||||
|
||||
func defaultClientConfigPath() string {
|
||||
root := os.Getenv("ProgramData")
|
||||
if root == "" {
|
||||
root = `C:\ProgramData`
|
||||
}
|
||||
return filepath.Join(root, "RVBox", "client.toml")
|
||||
}
|
||||
|
||||
func runService(configPath string, diagnostics io.Writer) error {
|
||||
inService, err := svc.IsWindowsService()
|
||||
if err != nil {
|
||||
return fmt.Errorf("detect service control manager context: %w", err)
|
||||
}
|
||||
if !inService {
|
||||
return errors.New("--service is reserved for the installed Windows service")
|
||||
}
|
||||
return runWindowsService(configPath, diagnostics)
|
||||
}
|
||||
|
||||
func runWindowsService(configPath string, diagnostics io.Writer) error {
|
||||
return windowsservice.Run(func(ctx context.Context) error { return runClientDaemon(ctx, configPath, diagnostics) })
|
||||
}
|
||||
|
||||
func runTray(configPath string, diagnostics io.Writer) error {
|
||||
return errors.New("Windows tray frontend is not available in this build")
|
||||
}
|
||||
Reference in New Issue
Block a user