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 Manage(g interface{}, name ...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
- type Graceful
- type GracefulFunc
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 force development settings that are otherwise autodetected by the presense of a Development folder in the user home directory Env() will mirror all final struct env:TAG=value to the os environment
func Manage ¶
func Manage(g interface{}, name ...string)
Manage start/stop gracefully requires Graceful interface signature or a graceful function with with a graceful signature following func(ctx context.Context) format; the optional name is automatically extracted from Graceful interface types or is randomly generated when a name is not supplied with a graceful function
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 // default hourly
// contains filtered or unexported fields
}
Expire is an file expiration manager
func NewExpire ¶ added in v1.1.0
NewExpire configurator will apply default settings and configure path items when provided