Documentation
¶
Index ¶
- Variables
- func Args(m map[string]string) map[string]string
- func Conf(path string, m map[string]string) map[string]string
- func Context() context.Context
- func Development() bool
- func Env() bool
- func Fork(pidPath *Dir, cfg ...interface{})
- func Info(cfg ...interface{})
- func Init(cfg ...interface{})
- func Manager(g interface{})
- func NewExpire(path ...string)
- func Parser(args, conf map[string]string, env bool, cfg ...interface{})
- func Ready()
- func Shutdown()
- func Stop()
- func Summary(cfg ...interface{})
- type Dir
- type Expire
Constants ¶
This section is empty.
Variables ¶
var ( Identity = filepath.Base(os.Args[0]) // Identity of app, as configured here Version string // Version information, set by a builder.sh Build string // Build information, set by a builder.sh Description string // Brief description, license, copyright EtcPath Dir = "/etc" // EtcPath base path SrvPath Dir = "/srv" // SrvPath base path VarPath Dir = "/var" // VarPath base path )
default configuration setting
Functions ¶
func Args ¶
Args processes os.Args and builds a m map[string]string; support for single reference switches -a aa -b=bb -c:cc formats; pass nil to create new
func Conf ¶
Conf processes a basic ini style file to build m map[string]string from the file; supports single reference k=v, k:v or k v setting; ignores comments and empty values; pass nil to create new
func Development ¶
func Development() bool
Development flag toggle; apply development setting in Init()
func Env ¶
func Env() bool
Env flag toggle; mirror all struct env:TAG=value to os environment via Parser()
func Fork ¶
func Fork(pidPath *Dir, cfg ...interface{})
Fork is an alternative Init that enables a program to run normally or like a daemon start|stop process; pidPath directory must exist and the user must have r/w file level permissions for proper operation; pass nil for default
func Info ¶
func Info(cfg ...interface{})
Info on version or help request processor
prog version|-version|--version prog help|-help|--help
func Init ¶
func Init(cfg ...interface{})
Init processe populates cfg structs by applying cfg struct default tag values, then any conf file (/etc/{identity}/{identity}.conf) values, then environment settings, then command line os.Args values to fill supported struct type fields; pass nil to load args or conf automatically
configuration toggles:
Development() will toggle development settings that are otherwise autodetected by the presense of a non-linux operating system; linux is always production Env() will mirror all final struct env:TAG=value to the os environment
func Manager ¶ added in v1.4.0
func Manager(g interface{})
Manager places the struct or func under graceful management and references it by name and requires the function sigature of 'func(ctx context.Context)', so any closure must return the graceful signature to operate properly as well.
A graceful struct must have a 'Start()' method with the proper graceful signature, and to override the use the struct name as defined in the code a struct my define an optional 'Name() string' signature method to provide an alternative name reference.
The use of any params passed to a struct or function that uses a closure will make the sequence run lock-step. To aloid this, wrap the closure head in a go routine.
func NewExpire ¶ added in v1.1.0
func NewExpire(path ...string)
NewExpire is an Expire wrapper that will create and start a file expiration manger under env.Manager control using default values applied to the direcory paths that are passed as paramaters.
Configure *Expire directly when custom settings are desired.
func Parser ¶
Parser will apply cfg struct default tag values, then any conf file (/etc/{identity}/{identity}.conf) values, then environment settings, followed by command line args values to fill supported struct type fields; pass nil to load args or conf automatically; set env=true to write KEY=value to os.Environ table
tag: env - name to use for configuration setting tag: default - set default value tag: help - help description
supports string, bool, int, int64, uint, uint64 struct types
func Shutdown ¶
func Shutdown()
Shutdown waits for a termination signal, initiates graceful cleanup, then calls os.Exit; Stop() or an os.Interrupt or os.Kill signal is trigger event; configure only once
Types ¶
type Dir ¶
type Dir string
Dir type
func (Dir) Create ¶
Create appends a... and return an updated string; create the directory tree when it does not exist and return a string representation of the full composite path. A file is presumend when the last element contains any of the following ._- characters.
conf.VarPath.Create() -> /var/log
conf.VarPath.Create("insite") -> /var/log/insite
conf.VarPath.Create("insite.log") -> /var/log/insite.log
conf.VarPath.Create("insite","insite.log") -> /var/log/insite/iniste.log
type Expire ¶ added in v1.1.0
type Expire struct {
CheckOn time.Duration // frequency of checks (default: hourly)
// contains filtered or unexported fields
}
Expire is an file expiration manager
func (*Expire) Add ¶ added in v1.1.0
Add will register a directory path with customized age timeframe