Documentation
¶
Index ¶
- Constants
- func AutostartStatus() error
- func DaemonizeSetup(paths *Paths) error
- func DisableAutostart() error
- func EnableAutostart(configPath string, port int) error
- func FindBinary() (string, error)
- func ForkIntoBackground(opts BackgroundOpts) error
- func GetPID(pidPath string) (int, error)
- func IsAppProcess(pid int, appName string) bool
- func IsProcessRunning(pid int) bool
- func StopProcess(pid int) error
- func WritePID(pidPath string, pid int) (err error)
- type BackgroundOpts
- type Paths
Constants ¶
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 ¶
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 ¶
EnableAutostart creates a .desktop file in ~/.config/autostart/.
func FindBinary ¶
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 IsAppProcess ¶ added in v0.3.5
func IsProcessRunning ¶
IsProcessRunning checks if a process with the given PID is running.
func StopProcess ¶
StopProcess sends SIGTERM to a process and waits for it to exit.
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 ¶
DefaultPaths computes paths from the user's home directory.
func (*Paths) EnsureConfigDir ¶
EnsureConfigDir creates ~/.config/routatic-proxy/ if it does not exist.