daemon

package
v0.4.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 22, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ComprehensiveStatus

type ComprehensiveStatus struct {
	Daemon  *DaemonStatus       `json:"daemon"`
	Service *ServiceStatus      `json:"service"`
	Config  *DaemonConfigStatus `json:"config"`
}

ComprehensiveStatus contains all daemon status information

type Daemon

type Daemon struct {
	// contains filtered or unexported fields
}

Daemon represents the sync daemon process

func NewDaemon

func NewDaemon(cfg *config.Config) (*Daemon, error)

NewDaemon creates a new daemon instance

func (*Daemon) GetStatus

func (d *Daemon) GetStatus() *DaemonStatus

GetStatus returns the current daemon status

func (*Daemon) Start

func (d *Daemon) Start() error

Start starts the daemon process

func (*Daemon) Stop

func (d *Daemon) Stop() error

Stop gracefully stops the daemon

type DaemonConfigStatus

type DaemonConfigStatus struct {
	SyncInterval  time.Duration `json:"sync_interval"`
	AutoStart     bool          `json:"auto_start"`
	SystemService bool          `json:"system_service"`
	PIDFile       string        `json:"pid_file"`
	LogFile       string        `json:"log_file"`
	LogLevel      string        `json:"log_level"`
}

DaemonConfigStatus contains daemon configuration information

type DaemonStatus

type DaemonStatus struct {
	Running       bool          `json:"running"`
	PID           int           `json:"pid,omitempty"`
	Uptime        time.Duration `json:"uptime,omitempty"`
	LastSync      time.Time     `json:"last_sync,omitempty"`
	SyncCount     int64         `json:"sync_count"`
	ErrorCount    int64         `json:"error_count"`
	SyncInterval  time.Duration `json:"sync_interval"`
	AutoStart     bool          `json:"auto_start"`
	SystemService bool          `json:"system_service"`
}

DaemonStatus represents the current status of the daemon

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager handles daemon lifecycle and service management

func NewManager

func NewManager(cfg *config.Config) *Manager

NewManager creates a new daemon manager instance

func (*Manager) Close

func (m *Manager) Close() error

Close cleans up manager resources

func (*Manager) GetStatus

func (m *Manager) GetStatus() (*ComprehensiveStatus, error)

GetStatus returns comprehensive daemon status

func (*Manager) InstallSystemService

func (m *Manager) InstallSystemService() error

InstallSystemService installs the system service

func (*Manager) IsAutoStartNeeded

func (m *Manager) IsAutoStartNeeded() bool

IsAutoStartNeeded checks if auto-start should be triggered

func (*Manager) RemoveSystemService

func (m *Manager) RemoveSystemService() error

RemoveSystemService removes the system service

func (*Manager) RestartDaemon

func (m *Manager) RestartDaemon() error

RestartDaemon restarts the daemon

func (*Manager) SetupBackgroundSync

func (m *Manager) SetupBackgroundSync() error

SetupBackgroundSync sets up background sync during initialization This is called during 'ccr init' when sync is enabled

func (*Manager) StartDaemon

func (m *Manager) StartDaemon() error

StartDaemon starts the daemon using the configured method

func (*Manager) StopDaemon

func (m *Manager) StopDaemon() error

StopDaemon stops the daemon

func (*Manager) TriggerAutoStart

func (m *Manager) TriggerAutoStart() error

TriggerAutoStart starts the daemon if auto-start conditions are met

type PIDManager

type PIDManager struct {
	// contains filtered or unexported fields
}

PIDManager handles PID file operations for daemon lifecycle management

func NewPIDManager

func NewPIDManager(pidFile string) *PIDManager

NewPIDManager creates a new PID manager instance

func (*PIDManager) CleanupStalePIDFile

func (pm *PIDManager) CleanupStalePIDFile() error

CleanupStalePIDFile removes PID file if the process is not running

func (*PIDManager) GetPIDFile

func (pm *PIDManager) GetPIDFile() string

GetPIDFile returns the path to the PID file

func (*PIDManager) GetStatus

func (pm *PIDManager) GetStatus() (*PIDStatus, error)

GetStatus returns status information about the daemon

func (*PIDManager) IsProcessRunning

func (pm *PIDManager) IsProcessRunning(pid int) bool

IsProcessRunning checks if a process with the given PID is running

func (*PIDManager) IsRunning

func (pm *PIDManager) IsRunning() bool

IsRunning checks if the daemon process is currently running

func (*PIDManager) KillDaemon

func (pm *PIDManager) KillDaemon() error

KillDaemon gracefully kills the daemon process

func (*PIDManager) ReadPID

func (pm *PIDManager) ReadPID() (int, error)

ReadPID reads the PID from the PID file

func (*PIDManager) RemovePID

func (pm *PIDManager) RemovePID() error

RemovePID removes the PID file

func (*PIDManager) ValidatePIDFile

func (pm *PIDManager) ValidatePIDFile() error

ValidatePIDFile checks if the PID file is valid and cleans up if necessary

func (*PIDManager) WritePID

func (pm *PIDManager) WritePID() error

WritePID writes the current process PID to the PID file

type PIDStatus

type PIDStatus struct {
	PIDFile   string        `json:"pid_file"`
	PID       int           `json:"pid"`
	Running   bool          `json:"running"`
	StartTime time.Time     `json:"start_time,omitempty"`
	Uptime    time.Duration `json:"uptime,omitempty"`
	Error     string        `json:"error,omitempty"`
}

PIDStatus contains status information about the daemon process

type ServiceManager

type ServiceManager struct {
	// contains filtered or unexported fields
}

ServiceManager handles system service integration for daemon auto-start

func NewServiceManager

func NewServiceManager(cfg *config.Config) *ServiceManager

NewServiceManager creates a new service manager instance

func (*ServiceManager) CreateSystemService

func (sm *ServiceManager) CreateSystemService() error

CreateSystemService creates an OS-appropriate system service

func (*ServiceManager) GetServiceStatus

func (sm *ServiceManager) GetServiceStatus() (*ServiceStatus, error)

GetServiceStatus returns the status of the system service

func (*ServiceManager) IsSystemServiceInstalled

func (sm *ServiceManager) IsSystemServiceInstalled() bool

IsSystemServiceInstalled checks if the system service is installed

func (*ServiceManager) RemoveSystemService

func (sm *ServiceManager) RemoveSystemService() error

RemoveSystemService removes the system service

func (*ServiceManager) RestartSystemService

func (sm *ServiceManager) RestartSystemService() error

RestartSystemService restarts the system service

func (*ServiceManager) StartSystemService

func (sm *ServiceManager) StartSystemService() error

StartSystemService starts the system service

func (*ServiceManager) StopSystemService

func (sm *ServiceManager) StopSystemService() error

StopSystemService stops the system service

type ServiceStatus

type ServiceStatus struct {
	Installed bool   `json:"installed"`
	Enabled   bool   `json:"enabled"`
	Running   bool   `json:"running"`
	Platform  string `json:"platform"`
}

ServiceStatus represents the status of the system service

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL