config

package
v0.1.0-alpha.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2016 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// EscalationInterval is used as the default value when none is given to
	// service.Stop() as the time to wait before increasing urgency of signal
	EscalationInterval = 10 * time.Second
)

Variables

View Source
var (
	// Version of the package
	Version = semver.MustParse("0.1.0-alpha.2.2")

	// ServiceConfigFile is the full path to the config file that lists
	// services to be read on server startup. If the path doesn't exist,
	// this'll be empty.
	ServiceConfigFile string

	// LogLevel determines the severity of messages that are logged.
	LogLevel = log.LvlWarn

	// LogPath is the path to the server's log file.
	LogPath = "bento.log"

	// FifoPath is the path to a unix named pipe that's used to communicate
	// between clients & the server.
	FifoPath = ".fifo"

	// HeartbeatInterval is the frequency that the fifo file is touched to
	// indicate a live server.
	HeartbeatInterval = 10 * time.Second

	// CleanTempServicesAfter is the interval after which an exited temp
	// service is removed.
	CleanTempServicesAfter = 1 * time.Hour
)

Functions

func Load

func Load(isServer bool) error

Load reads the config file and populates the global conf. It also handles creating the dir in the user's home if it doesn't exist, and populating an empty log file with comments, to guide the user.

Types

type ConfFormat

type ConfFormat struct {
	LogLevel               string `yaml:"log_level"`
	LogPath                string `yaml:"log"`
	FifoPath               string `yaml:"fifo"`
	CleanTempServicesAfter string `yaml:"clean_temp_services_after"`
}

ConfFormat is the yaml definition of the config file

type Service

type Service struct {
	Name string `yaml:"name"`

	// What to run
	Program string   `yaml:"program"`
	Args    []string `yaml:"args,omitempty"`

	// Runtime env
	Dir string            `yaml:"dir,omitempty"`
	Env map[string]string `yaml:"env,omitempty"`

	// Behavior
	AutoStart     bool `yaml:"auto-start,omitempty"`
	RestartOnExit bool `yaml:"restart-on-exit,omitempty"`

	// Temp is true if this config isn't loaded from a file, created at runtime
	Temp       bool          `yaml:",omitempty"`
	CleanAfter time.Duration `yaml:",omitempty"`
}

Service is the settings a service is made from

func LoadServiceFile

func LoadServiceFile(path string) ([]Service, error)

LoadServiceFile reads a file for a list of service confs, sanitizing them all

func (*Service) EqualIgnoringSafeFields

func (s *Service) EqualIgnoringSafeFields(s2 *Service) bool

EqualIgnoringSafeFields returns true if the service config equals another, ignoring fields that can be safely changed on a running service.

func (*Service) Sanitize

func (s *Service) Sanitize() error

Sanitize checks a config for valitidy, and fixes up values that are dynamic or have defaults.

type ServiceByName

type ServiceByName []Service

ServiceByName implements the sort interface

func (ServiceByName) Len

func (i ServiceByName) Len() int

func (ServiceByName) Less

func (i ServiceByName) Less(a, b int) bool

func (ServiceByName) Swap

func (i ServiceByName) Swap(a, b int)

Jump to

Keyboard shortcuts

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