Skip to content

Commit

Permalink
Merge pull request #139 from mountaindude/master
Browse files Browse the repository at this point in the history
4.0.3 RC2
  • Loading branch information
mountaindude authored Jan 5, 2022
2 parents 6c04fc1 + 43ab767 commit d209f4c
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 30 deletions.
40 changes: 22 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,38 +164,43 @@ drwxr-xr-x 5 goran staff 160 Sep 27 10:43 ..
-rw-r--r--@ 1 goran staff 1192 Sep 27 10:43 root.pem
```

What do the config files look like?
What does a real-world config file look like?

```bash
proton:butler-cw-docker goran$ cat config/production.yaml
# Rename this file to production.yaml, and fill in data as needed below.
# Logging configuration
logLevel: verbose # Log level. Possible log levels are silly, debug, verbose, info, warn, error
fileLogging: true # true/false to enable/disable logging to disk file
logLevel: info # Log level. Valid log levels are silly, debug, verbose, info, warn, error
fileLogging: true # true/false to enable/disable logging to disk file
# Configuration of Butler CW's scheduler
scheduler:
startup:
showPerAppSchedule:
enable: true # Should the first itemCount scheduled runs be shown for each app, on startup?
itemCount: 10 # Number of coming runs to show for each app
enable: true # Should the first itemCount scheduled runs be shown for each app, on startup?
itemCount: 10 # Number of coming runs to show for each app
timeZone: # Valid values are UTC and LOCAL. Default value is UTC
scheduleDefine: UTC # How should times in the apps config file be interpreted?
logs: UTC # What time format should be used in log files?
logs: UTC # What time format should be used in log files?
showNextEvent:
enable: true # Should date/time of next cache warming event be sent to log file? (true/false)
logLevel: warn # Log level to use for the next event log entry. Valid values are silly, debug, verbose, info, warn, error
tzFormat: UTC # LOCAL or UTC. Default is UTC
# Heartbeats can be used to send "I'm alive" messages to some other tool, e.g. an infrastructure monitoring tool
# The concept is simple: The remoteURL will be called at the specified frequency. The receiving tool will then know
# Heartbeats can be used to send "I'm alive" messages to any other tool, e.g. a infrastructure monitoring tool
# The concept is simple: The remoteURL will be called at the specified frequency. The receiving tool will then know
# that Butler CW is alive.
heartbeat:
enabled: true
remoteURL: http://healthcheck.ptarmiganlabs.net/ping/138514b0-882a-4a44-8548-96f7d16c9242
frequency: every 30 seconds # https://bunkat.github.io/later/parsers.html
remoteURL: https://healthcheck.ptarmiganlabs.net/ping/138514b0-882a-4a44-8548-96f7d16c9242
# frequency: every 1 minute # https://bunkat.github.io/later/parsers.html
frequency: every 10 seconds # https://bunkat.github.io/later/parsers.html
# Docker health checks are used when running Butler CW as a Docker container.
# Docker health checks are used when running Butler CW as a Docker container.
# The Docker engine will call the container's health check REST endpoint with a set interval to determine
# whether the container is alive/well or not.
# If you are not running Butler CW in Docker you can safely disable this feature.
# If you are not running Butler CW in Docker you can safely disable this feature.
dockerHealthCheck:
enabled: true # Control whether a REST endpoint will be set up to serve Docker health check messages
port: 12398 # Port the Docker health check service runs on (if enabled)
Expand All @@ -204,7 +209,7 @@ dockerHealthCheck:
# When enabled, Butler CW will write info on uptime and used memory to log files
uptimeMonitor:
enabled: true # Should uptime messages be written to the console and log files?
frequency: every 60 seconds # https://bunkat.github.io/later/parsers.html
frequency: every 10 seconds # https://bunkat.github.io/later/parsers.html
logLevel: verbose # Starting at what log level should uptime messages be shown?
# Paths to client certificates to use when connecting to Sense server. Can be pem or pvk/cer
Expand All @@ -218,10 +223,9 @@ mqttConfig:
out:
enable: true # Should info about cache run/warming events be sent as MQTT messages?
baseTopic: butler-cw/ # Topic to send cache run events to. Should end with /
tzFormat: UTC # LOCAL or UTC. Default is UTC
# Items below are mandatory if mqttConfig.enable=true
broker:
uri: mqtt://1.2.3.4:1883 ## Port is usually 1883
tzFormat: UTC # LOCAL or UTC. Default is UTC
broker: # MQTT server/broker config
uri: mqtt://1.2.3.4:1883 ## Port is usually 1883
# QIX version to use
qixVersion: 12.170.2
Expand All @@ -230,7 +234,7 @@ qixVersion: 12.170.2
appConfig:
# Valid options are disk, github
configSource: disk
# Leave strings empty if disk config not used
diskConfigFile: ./config/apps.yaml
Expand Down
12 changes: 12 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

### [4.0.2](https://www.github.com/ptarmiganlabs/butler-cw/compare/butler-cw-v4.0.1...butler-cw-v4.0.2) (2021-12-01)


### Bug Fixes

* Slim down release ZIP artefacts ([742c180](https://www.github.com/ptarmiganlabs/butler-cw/commit/742c1805e4d2eb15293a7ef9ffc8de24af6d1d70))


### Miscellaneous

* **deps:** Update dependencies ([5b75ad2](https://www.github.com/ptarmiganlabs/butler-cw/commit/5b75ad2f9732e64ad66655fb8a9450dd9b5f3d38))

### [4.0.1](https://www.github.com/ptarmiganlabs/butler-cw/compare/butler-cw-v4.0.0...butler-cw-v4.0.1) (2021-10-26)


Expand Down
4 changes: 2 additions & 2 deletions config/default_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ dockerHealthCheck:
# Uptime monitor
# When enabled, Butler CW will write info on uptime and used memory to log files
uptimeMonitor:
enabled: true # Should uptime messages be written to the console and log files?
enabled: false # Should uptime messages be written to the console and log files?
frequency: every 60 seconds # https://breejs.github.io/later/parsers.html#text
logLevel: verbose # Starting at what log level should uptime messages be shown?

Expand All @@ -54,7 +54,7 @@ clientCertCAPath: /path/to/client/cert/root.pem
# MQTT config parameters
mqttConfig:
out:
enable: true # Should info about cache run/warming events be sent as MQTT messages?
enable: false # Should info about cache run/warming events be sent as MQTT messages?
baseTopic: butler-cw/ # Topic to send cache run events to. Should end with /
tzFormat: UTC # LOCAL or UTC. Default is UTC
broker: # MQTT server/broker config
Expand Down
43 changes: 33 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,10 @@ async function loadAppIntoCache(appConfig) {
// const sched = later.parse.text(appConfig.freq);
let nextRun;

if (globals.config.get('mqttConfig.out.tzFormat').toLowerCase() === 'local') {
if (
globals.config.has('mqttConfig.out.tzFormat') &&
globals.config.get('mqttConfig.out.tzFormat').toLowerCase() === 'local'
) {
// Use local timezone
nextRun = nextOccurrences[1].toString();
} else {
Expand All @@ -181,10 +184,15 @@ async function loadAppIntoCache(appConfig) {

// eslint-disable-next-line no-param-reassign
appConfig.nextRun = nextRun;
mqttClient.publish(
globals.config.get('mqttConfig.out.baseTopic'),
JSON.stringify(appConfig)
);
if (
globals.config.has('mqttConfig.out.enable') &&
globals.config.get('mqttConfig.out.enable') === true
) {
mqttClient.publish(
globals.config.get('mqttConfig.out.baseTopic'),
JSON.stringify(appConfig)
);
}
});
} else {
app.session.close();
Expand Down Expand Up @@ -279,7 +287,10 @@ async function mainScript() {
: null;

// Start Docker healthcheck REST server on port set in config file
if (globals.config.get('dockerHealthCheck.enabled') === true) {
if (
globals.config.has('dockerHealthCheck.enabled') &&
globals.config.get('dockerHealthCheck.enabled') === true
) {
try {
globals.logger.verbose('MAIN: Starting Docker healthcheck server...');

Expand All @@ -306,12 +317,18 @@ async function mainScript() {
}

// Set up heartbeats, if enabled in the config file
if (globals.config.get('heartbeat.enabled') === true) {
if (
globals.config.has('heartbeat.enabled') &&
globals.config.get('heartbeat.enabled') === true
) {
heartbeat.setupHeartbeatTimer(globals.config);
}

// Set up uptime logging
if (globals.config.get('uptimeMonitor.enabled') === true) {
if (
globals.config.has('uptimeMonitor.enabled') &&
globals.config.get('uptimeMonitor.enabled') === true
) {
serviceUptime.serviceUptimeStart(globals.config);
}

Expand All @@ -337,10 +354,16 @@ async function mainScript() {

// Load cache warming config
try {
if (globals.config.get('appConfig.configSource') === 'disk') {
if (
globals.config.has('appConfig.configSource') &&
globals.config.get('appConfig.configSource') === 'disk'
) {
appConfigYaml = fs.readFileSync(globals.config.get('appConfig.diskConfigFile'), 'utf8');
loadAppConfig(appConfigYaml);
} else if (globals.config.get('appConfig.configSource') === 'github') {
} else if (
globals.config.has('appConfig.configSource') &&
globals.config.get('appConfig.configSource') === 'github'
) {
const github = new GitHubApi({
// optional
// debug: true,
Expand Down

0 comments on commit d209f4c

Please sign in to comment.