mirror of https://github.com/jetkvm/kvm.git
feat: allow to override max restart attempts
This commit is contained in:
parent
64ec70d030
commit
d84eb56c21
|
|
@ -107,6 +107,7 @@ type Config struct {
|
||||||
DefaultLogLevel string `json:"default_log_level"`
|
DefaultLogLevel string `json:"default_log_level"`
|
||||||
VideoSleepAfterSec int `json:"video_sleep_after_sec"`
|
VideoSleepAfterSec int `json:"video_sleep_after_sec"`
|
||||||
VideoQualityFactor float64 `json:"video_quality_factor"`
|
VideoQualityFactor float64 `json:"video_quality_factor"`
|
||||||
|
NativeMaxRestart uint `json:"native_max_restart_attempts"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Config) GetDisplayRotation() uint16 {
|
func (c *Config) GetDisplayRotation() uint16 {
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,9 @@ func (n *NativeOptions) toProxyOptions() *nativeProxyOptions {
|
||||||
// random 16 bytes hex string
|
// random 16 bytes hex string
|
||||||
handshakeMessage := randomId(16)
|
handshakeMessage := randomId(16)
|
||||||
maxRestartAttempts := defaultMaxRestartAttempts
|
maxRestartAttempts := defaultMaxRestartAttempts
|
||||||
if n.MaxRestartAttempts > 0 {
|
// though it's unlikely to be less than 0 as it's uint, we'll add it just in case
|
||||||
|
// until we have a proper unit test for all things :-(
|
||||||
|
if n.MaxRestartAttempts <= 0 {
|
||||||
maxRestartAttempts = n.MaxRestartAttempts
|
maxRestartAttempts = n.MaxRestartAttempts
|
||||||
}
|
}
|
||||||
return &nativeProxyOptions{
|
return &nativeProxyOptions{
|
||||||
|
|
@ -330,7 +332,12 @@ func (p *NativeProxy) start() error {
|
||||||
return fmt.Errorf("failed to start native process: %w", err)
|
return fmt.Errorf("failed to start native process: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
p.logger.Info().Int("pid", p.cmd.Process.Pid).Msg("native process started")
|
// here we'll replace the logger with a new one that includes the process ID
|
||||||
|
// there's no need to lock the mutex here as the side effect is acceptable
|
||||||
|
newLogger := p.logger.With().Int("pid", p.cmd.Process.Pid).Logger()
|
||||||
|
p.logger = &newLogger
|
||||||
|
|
||||||
|
p.logger.Info().Msg("native process started")
|
||||||
|
|
||||||
if err := p.setUpGRPCClient(); err != nil {
|
if err := p.setUpGRPCClient(); err != nil {
|
||||||
return fmt.Errorf("failed to set up gRPC client: %w", err)
|
return fmt.Errorf("failed to set up gRPC client: %w", err)
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ func initNative(systemVersion *semver.Version, appVersion *semver.Version) {
|
||||||
AppVersion: appVersion,
|
AppVersion: appVersion,
|
||||||
DisplayRotation: config.GetDisplayRotation(),
|
DisplayRotation: config.GetDisplayRotation(),
|
||||||
DefaultQualityFactor: config.VideoQualityFactor,
|
DefaultQualityFactor: config.VideoQualityFactor,
|
||||||
|
MaxRestartAttempts: config.NativeMaxRestart,
|
||||||
OnNativeRestart: func() {
|
OnNativeRestart: func() {
|
||||||
configureDisplayOnNativeRestart()
|
configureDisplayOnNativeRestart()
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue