Documentation
¶
Overview ¶
Package runenv locates the run, install, log and config paths of the process, reports its uptime and serves pprof on request.
Index ¶
- Variables
- func FileExists(name string) bool
- func GetAppPath() string
- func GetConfigPath() string
- func GetEnvMap() map[string]string
- func GetInstallPath() string
- func GetLogPath() string
- func GetNpcLogPath() string
- func GetPath(filePath string) string
- func GetRunPath() string
- func GetRunSecs() int64
- func GetRunTime() string
- func GetStartTime() int64
- func InitPProfByAddr(addr string)
- func IsWindows() bool
- func LogDefaults(typ string, size, files int) (string, int, int)
- func ResolvePath(path string) string
- func SetSoftMemoryLimit() int64
Constants ¶
This section is empty.
Variables ¶
var ( // ConfPath overrides the install path when set. ConfPath string )
var OnOpenWrt = sync.OnceValue(func() bool { if runtime.GOOS != "linux" { return false } _, err := os.Stat("/etc/openwrt_release") return err == nil })
OnOpenWrt reports whether this is an OpenWrt system. Its devices often have little memory, /var is a RAM disk and /etc is flash, so nps and npc log nothing there unless told to, as the OpenWrt packages do.
Functions ¶
func FileExists ¶
FileExists reports whether the named file or directory exists.
func GetAppPath ¶
func GetAppPath() string
GetAppPath Get the absolute path to the running directory
func GetInstallPath ¶
func GetInstallPath() string
GetInstallPath Different systems get different installation paths
func GetRunPath ¶
func GetRunPath() string
GetRunPath Get the currently selected configuration file directory For non-Windows systems, select the /etc/nps as config directory if exist, or select ./ windows system, select the C:\Program Files\nps as config directory if exist, or select ./
func GetRunSecs ¶
func GetRunSecs() int64
func GetRunTime ¶
func GetRunTime() string
func GetStartTime ¶
func GetStartTime() int64
func InitPProfByAddr ¶
func InitPProfByAddr(addr string)
InitPProfByAddr serves pprof on addr, host:port; an empty host is the loopback address, as the profiles show the process's memory.
func IsWindows ¶
func IsWindows() bool
IsWindows Determine whether the current system is a Windows system?
func LogDefaults ¶
LogDefaults returns the default log mode, file size in MB and number of files: off, 1 and 1 on OpenWrt, else typ, size and files.
func ResolvePath ¶
func SetSoftMemoryLimit ¶ added in v0.35.4
func SetSoftMemoryLimit() int64
SetSoftMemoryLimit gives the Go runtime a soft memory limit of half the total memory on a small device, so that the collector works harder before the system runs out of memory; the limit fails no allocation. GOMEMLIMIT, when set, wins. It returns the limit set, 0 for none.
Types ¶
This section is empty.