-
Notifications
You must be signed in to change notification settings - Fork 4
HUME_ Environment Variables
Instead of using -t "TASKNAME" or --tags "tag1,tag2" or even obscure parameters such as --recv-timeout, you can set those values in envirnoment variables
Just set HUME_TASKNAME environment variable to the current taskname.
export HUME_TASKNAME='TEST'
hume -L ok "ok test message"
hume -L warning "warning test message"
hume -t "SOMETHINGELSE" "overriding environment variable"
The first two messages will be emitted with TASKNAME='TEST'. The third hume command overrides the environment variable value.
In this case, HUME_TAGS will be appended to whatever tags are specified in the commandline:
export HUME_TAGS="envtag1, envtag2"
hume -L debug "Four tags" --tags clitag1,clitag2
If no other tags are indicated on the commandline, just $HUME_TAGS will be emitted.
Hume uses zeromq REPly/REQuest pattern to communicate with humed. As I indicated elsewhere, hume must limit its interference with whatever system administration scripts run. You can tweak how much humed will wait for a response from humed with the --recv-timeout parameter. Or you can specify it globally in the script using HUME_RECVTIMEOUT
Value is set in milliseconds. The default is 1000ms (one second).
Let's further enhance our wordpress update script:
#!/bin/bash
HUME_TASKNAME='WEBAPP_UPDATES'
HUME_TAGS='wordpress,cron'
HUME_RECVTIMEOUT=5000 # 5s timeout
hume -a "Starting wp-cli run"
for dir in "/var/www/site1/htdocs" "/var/www/othersite/htdocs"
do
cd $dir
wp core update || hume -L warn "core update failed for $dir"
wp plugin update || hume -L warn "plugin update failed for $dir"
done
hume "Finished wp-cli run"
OFFTOPIC: If you use wordpress, check this out https://github.com/buanzo/wordpress-updater