internal

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2016 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package internal houses code for wr's general utility functions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultDeployment

func DefaultDeployment() (deployment string)

DefaultDeployment works out the default deployment.

func DefaultScheduler

func DefaultScheduler() (scheduler string)

DefaultScheduler works out the default scheduler (we need this to be able to report this default before we know what deployment the user has actually chosen, ie. before we have a final config).

func DefaultServer

func DefaultServer() (server string)

DefaultServer works out the default server (we need this to be able to report this default before we know what deployment the user has actually chosen, ie. before we have a final config).

func SortMapKeysByIntValue

func SortMapKeysByIntValue(imap map[string]int, reverse bool) (sortedKeys []string)

SortMapKeysByIntValue sorts the keys of a map[string]int by its values, reversed if you supply true as the second arg.

func SortMapKeysByMapIntValue

func SortMapKeysByMapIntValue(imap map[string]map[string]int, criterion string, reverse bool) (sortedKeys []string)

SortMapKeysByMapIntValue sorts the keys of a map[string]map[string]int by a the values found at a given sub value, reversed if you supply true as the second arg.

func Userid

func Userid() (uid int, err error)

Userid returns the user id of the current user. This avoids problems with static compilation as it avoids the use of os/user. It will only work on linux-like systems where 'id -u' works.

func Username

func Username() (uname string, err error)

Username returns the username of the current user. This avoids problems with static compilation as it avoids the use of os/user. It will only work on linux-like systems where 'id -u -n' works.

Types

type Config

type Config struct {
	ManagerPort      string `default:""`
	ManagerWeb       string `default:""`
	ManagerHost      string `default:"localhost"`
	ManagerDir       string `default:"~/.wr"`
	ManagerPidFile   string `default:"pid"`
	ManagerLogFile   string `default:"log"`
	ManagerDbFile    string `default:"db"`
	ManagerDbBkFile  string `default:"db_bk"`
	ManagerUmask     int    `default:"007"`
	ManagerScheduler string `default:"local"`
	RunnerExecShell  string `default:"bash"`
	Deployment       string `default:"production"`
}

Config holds the configuration options for jobqueue server and client

func ConfigLoad

func ConfigLoad(deployment string, useparentdir bool) Config

ConfigLoad loads configuration settings from files and environment variables. Note, this function exits on error, since without config we can't do anything.

We prefer settings in config file in current dir (or the current dir's parent dir if the useparentdir option is true (used for test scripts)) over config file in home directory over config file in dir pointed to by WR_CONFIG_DIR.

The deployment argument determines if we read .wr_config.production.yml or .wr_config.development.yml; we always read .wr_config.yml. If the empty string is supplied, deployment is development if you're in the git repository directory. Otherwise, deployment is taken from the environment variable WR_DEPLOYMENT, and if that's not set it defaults to production.

Multiple of these files can be used to have settings that are common to multiple users and deployments, and settings specific to users or deployments.

Settings found in no file can be set with the environment variable WR_<setting name in caps>, eg. export WR_MANAGER_PORT="11301"

Jump to

Keyboard shortcuts

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