feat(watchdog): add watchdog service with TCP client implementation
- Implement TCP client for watchdog service communication - Add watchdog configuration in config.json - Update main.go to initialize and connect to watchdog - Add watchdog related functions (connect, command handling) - Update README.md with new watchdog feature - Improve route setup logging in router.go
This commit is contained in:
@@ -17,6 +17,9 @@ type Config struct {
|
||||
FrpcPath string `json:"frpcPath"`
|
||||
InstancePath string `json:"instancePath"`
|
||||
Debug bool `json:"debug"`
|
||||
Watchdog struct {
|
||||
Port int `json:"port"`
|
||||
} `json:"watchdog"`
|
||||
}
|
||||
|
||||
type InstanceInfo struct {
|
||||
@@ -75,13 +78,21 @@ func LoadConfig(configPath string) (*Config, error) {
|
||||
}
|
||||
|
||||
if config.FrpcPath == "" {
|
||||
config.FrpcPath = "/usr/bin/frpc"
|
||||
if GetInitSystem() == "windows" {
|
||||
config.FrpcPath = "frp_client/frpc.exe"
|
||||
} else {
|
||||
config.FrpcPath = "/usr/bin/frpc"
|
||||
}
|
||||
}
|
||||
|
||||
if config.InstancePath == "" {
|
||||
config.InstancePath = "./configs"
|
||||
}
|
||||
|
||||
if config.Watchdog.Port == 0 {
|
||||
config.Watchdog.Port = 12380
|
||||
}
|
||||
|
||||
if err := os.MkdirAll(config.InstancePath, 0755); err != nil {
|
||||
return nil, fmt.Errorf("failed to create config directory: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user