uboot

package
v0.0.0-...-ea06120 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package uboot manages process startup, setting up logging, signal handling, and loading of components through golum and uconfig.

This works well for processes with minimal command line flags, and behavior defined by YAML config (see uconfig) (see golum).

func main() {
    _, err := uboot.SimpleBoot()
    if err != nil {
        ulog.Fatalf(..., err)
    }

    ...

    uexit.SimpleSignalHandling()
}

From the command line, it is possible to see what components are supported:

program -show all
program -show [component]

To run program:

program -config config.yml -log [stdout|logfile]

Index

Constants

This section is empty.

Variables

View Source
var (
	Testing = func() bool {
		syscall.Umask(002)
		return strings.HasSuffix(os.Args[0], ".test")
	}()
)

Functions

This section is empty.

Types

type Boot

type Boot struct {
	Name      string           // what program calls itself
	InstallD  string           // where program is installed
	ConfigF   string           // abs path to config file
	LogF      string           // path to log file, or empty/"stdout"
	LogSize   int64            // size of log file before rotate
	LogKeep   int              // logs to keep around
	Config    *uconfig.Section // the loaded config
	DryRun    bool             // is this a dry run (config check)?
	RedirectF string           // file to redirect stderr to

	//
	// set by build system.  examples:
	// go build -ldflags '-X /import/path.Version=#{$stamp}-#{REV}'
	// go build -ldflags '-X main.Version=#{$stamp}-#{REV}'
	//
	Version string
}

Control process boot

func SimpleBoot

func SimpleBoot() (rv Boot, err error)

simple boot using default values

func (*Boot) Boot

func (this *Boot) Boot() (err error)

bootstrap process to initial state. order matters.

func (*Boot) Configure

func (this *Boot) Configure(
	cspec string,
	beforeStart func(c *uconfig.Section) (err error),
) (
	config *uconfig.Section,
	err error,
)

Continue boot process: configure from ConfigF (if avail)

if cspec set, use golum to load the components listed in that section.

if beforeStart set, invoke the function after loading golum components but before starting them.

The following substitutions are automatically added for components: - name - configFile - logDir

invoke after Redirect() or logging initialized

func (*Boot) Redirect

func (this *Boot) Redirect() (err error)

Continue boot process: redirect stdin, stdout, stderr and setup logging

if logF is empty, then use configured setting, which may be "stdout"

invoke after Boot() or program initialized

func (*Boot) Simple

func (this *Boot) Simple() (err error)

simple boot using supplied Boot

Jump to

Keyboard shortcuts

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