Documentation
¶
Overview ¶
gokrazy packs your Go application(s) into an SD card image for the Raspberry Pi 3 which — aside from the Linux kernel and proprietary Raspberry Pi bootloader — only contains Go software.
Boot and Supervise are called by the auto-generated init program. They are provided in case you need to implement a custom init program.
PrivateInterfaceAddrs is useful for init and other processes.
DontStartOnBoot and WaitForClock are useful for non-init processes.
Index ¶
- Constants
- func Boot(userBuildTimestamp string) error
- func DontStartOnBoot()
- func IsInPrivateNet(ip net.IP) bool
- func MachineID() string
- func Model() string
- func NewProcessState() *processState
- func PrivateInterfaceAddrs() ([]string, error)
- func PublicInterfaceAddrs() ([]string, error)
- func ReadSBOM() (*json.RawMessage, string, error)
- func Supervise(commands []*exec.Cmd) errordeprecated
- func SuperviseServices(services []*Service) error
- func WaitForClock()
- type Service
Constants ¶
const ( Stopped statusCode = iota // Process not running Running // Process was started and is very likely still running Stopping // Process is being stopped, but it might still be running )
Variables ¶
This section is empty.
Functions ¶
func Boot ¶
Boot configures basic system settings. More specifically, it:
- mounts /dev, /tmp, /proc, /sys and /perm file systems
- mounts and populate /etc tmpfs overlay
- sets hostname from the /etc/hostname file
- sets HTTP password from the gokr-pw.txt file
- configures the loopback network interface
Boot should always be called to transition the machine into a useful state, even in custom init process implementations or single-process applications.
userBuildTimestamp will be exposed on the HTTP status handlers that are set up by Supervise.
func DontStartOnBoot ¶
func DontStartOnBoot()
DontStartOnBoot informs the gokrazy init process to not supervise the process and exits. The user can manually start supervision, which turns DontStartOnBoot into a no-op.
func IsInPrivateNet ¶
IsInPrivateNet reports whether the specified IP address is a private address, including loopback and link-local unicast addresses.
func MachineID ¶
func MachineID() string
MachineID returns the machine id (see https://manpages.debian.org/machine-id.5) of the running gokrazy instance.
`gok new` creates a random machine id, but on older gokrazy installations, the hostname is used as a fallback.
func Model ¶
func Model() string
Model returns a human readable description of the current device model, e.g. “Raspberry Pi 4 Model B Rev 1.1” or “PC Engines apu2”.
func NewProcessState ¶
func NewProcessState() *processState
func PrivateInterfaceAddrs ¶
PrivateInterfaceAddrs returns all private (as per RFC1918, RFC4193, RFC3330, RFC3513, RFC3927, RFC4291) host addresses of all active interfaces, suitable to be passed to net.JoinHostPort.
func PublicInterfaceAddrs ¶
PublicInterfaceAddrs returns all public (excluding RFC1918, RFC4193, RFC3330, RFC3513, RFC3927, RFC4291) host addresses of all active interfaces, suitable to be passed to net.JoinHostPort.
func SuperviseServices ¶
SuperviseServices continuously restarts the processes specified in services unless they run DontStartOnBoot.
Password-protected HTTP handlers are installed, allowing to inspect the supervised services and update the gokrazy installation over the network.
HTTP is served on PrivateInterfaceAddrs(). New IP addresses will be picked up upon receiving SIGHUP.
func WaitForClock ¶
func WaitForClock()
WaitForClock returns once the system clock appears to have been set. Assumes that the system boots with a clock value of January 1, 1970 UTC (UNIX epoch), as is the case on the Raspberry Pi 3.
Types ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is a gokrazy service.
func NewService ¶
NewService constructs a new gokrazy service from the specified command.
func NewStoppedService ¶
NewStoppedService is like NewService, but the created gokrazy service will not be supervised, i.e. remain stopped on boot.
func NewWaitForClockService ¶
NewWaitForClockService is like NewService, but the created gokrazy service will wait for clock to be synchronized, i.e. blocked till the clock is accurate.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
cmd
|
|
dhcp
dhcp is a minimal DHCP client for gokrazy.
|
dhcp is a minimal DHCP client for gokrazy. |
ntp
ntp is a minimal NTP client for gokrazy.
|
ntp is a minimal NTP client for gokrazy. |
randomd
Binary randomd carries entropy across restarts.
|
Binary randomd carries entropy across restarts. |
Package empty is pulled in only for the side-effect of checking out the gokrazy git repository.
|
Package empty is pulled in only for the side-effect of checking out the gokrazy git repository. |
Package ifaddr provides functions to obtain the private and public host addresses of all active interfaces.
|
Package ifaddr provides functions to obtain the private and public host addresses of all active interfaces. |
integration
|
|
internal
|
|
teelogger
Package teelogger provides loggers which send their output to multiple writers, like the tee(1) command.
|
Package teelogger provides loggers which send their output to multiple writers, like the tee(1) command. |