daemon

package
v0.3.9 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppName       = "routatic-proxy"
	LegacyAppName = "oc-go-cc"
	ConfigDir     = ".config/routatic-proxy"
	LaunchAgent   = "com.routatic.proxy"
)

Variables

This section is empty.

Functions

func AutostartStatus

func AutostartStatus() error

AutostartStatus reports whether autostart is enabled.

func DaemonizeSetup

func DaemonizeSetup(paths *Paths) error

DaemonizeSetup is called by the child process (when --_daemonize is set). It redirects stdout/stderr to the log file and writes the PID file.

func DisableAutostart

func DisableAutostart() error

DisableAutostart removes the .desktop file from ~/.config/autostart/.

func EnableAutostart

func EnableAutostart(configPath string, port int) error

EnableAutostart creates a .desktop file in ~/.config/autostart/.

func FindBinary

func FindBinary() (string, error)

FindBinary returns the absolute path to the routatic-proxy binary.

func ForkIntoBackground

func ForkIntoBackground(opts BackgroundOpts) error

ForkIntoBackground starts the current binary as a detached background process.

func GetPID

func GetPID(pidPath string) (int, error)

GetPID reads the PID from the PID file.

func IsAppProcess added in v0.3.5

func IsAppProcess(pid int, appName string) bool

func IsProcessRunning

func IsProcessRunning(pid int) bool

IsProcessRunning checks if a process with the given PID is running.

func StopProcess

func StopProcess(pid int) error

StopProcess sends SIGTERM to a process and waits for it to exit.

func WritePID

func WritePID(pidPath string, pid int) (err error)

WritePID writes the given PID to a file. Uses O_NOFOLLOW to atomically reject symlinks at open time, preventing symlink-traversal attacks (CWE-59).

Types

type BackgroundOpts

type BackgroundOpts struct {
	ConfigPath string // --config flag value, may be empty
	Port       int    // --port flag value, 0 means default
}

BackgroundOpts are the options passed from the serve command.

type Paths

type Paths struct {
	ConfigDir  string // ~/.config/routatic-proxy
	PIDFile    string // ~/.config/routatic-proxy/routatic-proxy.pid
	LogFile    string // ~/.config/routatic-proxy/routatic-proxy.log
	PlistPath  string // ~/Library/LaunchAgents/com.routatic.proxy.plist
	BinaryPath string // absolute path to the running executable
}

Paths holds well-known directories and files for the app.

func DefaultPaths

func DefaultPaths() (*Paths, error)

DefaultPaths computes paths from the user's home directory.

func (*Paths) EnsureConfigDir

func (p *Paths) EnsureConfigDir() error

EnsureConfigDir creates ~/.config/routatic-proxy/ if it does not exist.

Jump to

Keyboard shortcuts

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