Configuration - mrvisser/node-cowboy GitHub Wiki
Loading order
Cowboy's configuration is merged in priority order from 3 separate sources. The sources are:
- From the command arguments
--log-path <path to log file (or "stdout")>
will override anyconfig.log.path
config spec--log-level <trace | debug | info | warn | error>
will override anyconfig.log.level
config spec
- From a configuration file on disk
- The configuration file lookup happens in the following order:
a. If the
--config <path/to/config/file.json>
argument is specified, it will be loaded from there b. If~/.cowboy/cowboy.config.json
exists, it will be loaded from there c. If/etc/cowboy/cowboy.config.json
exists, it will be loaded from there
- Defaults hard-coded within the source code
Full Sample Configuration
{
"data": {},
"log": {
"level": "info",
"path": null
},
"modules": {
"dir": null,
"npm": "npm"
},
"redis": {
"host": "127.0.0.1",
"port": 6379,
"index": 0
}
}
Configuration Keys
Data
The data
component is used primarily by the cattle server, and holds information about the cattle node itself. Currently, the only data key that matters is hostname
.
data.hostname
Specifies the "host" of the machine. If unspecified, the hostname of the cattle server will be derived using the Node.js function os.hostname()
.
Logging
Configures the logger of the system. This does not include console output from Cowboy commands, but rather internal system logging that can be useful to diagnose issues.
log.path
Specifies the path to the log file, if any. If unspecified, or if the literal string "stdout"
, then logging will be output to standard out.
log.level
Specifies the log level. Should be one of trace, debug, info, warn, error
. If unspecified, will be info
.
Modules
Configures how modules are loaded and installed in the system.
modules.dir
The directory in which modules are installed and loaded. This directory will eventually have a node_modules
directory underneath it for NPM installs, so it does not have to point to a node_modules
directory itself. If unspecified, will default to .
of the current working directory of the process.
modules.npm
The executable to use to invoke npm
. If unspecified, defaults to npm
, which assumes that npm
is on the process PATH.
Redis
Tells both the cowboy client and cattle servers where to connect to Redis.
redis.host
The host name (or IP address) where Redis can be found. Defaults to 127.0.0.1.
redis.port
The Redis port. Defaults to 6379.
redis.index
The Redis DB index to connect to for Pub/Sub. Defaults to 0.
redis.username
The username to use to authenticate to the Redis server. By default, there is no authentication.
redis.password
The password to use to authenticate to the Redis server. By default, there is no authentication.