Merge pull request #532 from ungleich/prometheus-fixes

fix missing dependencies in __prometheus_*, __go_get
This commit is contained in:
Darko Poljak 2017-06-16 10:04:58 +02:00 committed by GitHub
commit ad51d4e0f6
10 changed files with 23 additions and 32 deletions

View file

@ -24,7 +24,7 @@ from-package
BOOLEAN PARAMETERS
------------------
install-init-script
Add an init script and set it to start on boot. Default yes.
Add an init script and set it to start on boot.
EXAMPLES
--------

View file

@ -1 +1 @@
command -v svc
command -v svc || true

View file

@ -15,3 +15,4 @@ case $os in
;;
esac
__package git

View file

@ -10,6 +10,9 @@ DESCRIPTION
-----------
Install and configure Prometheus Alertmanager (https://prometheus.io/docs/alerting/alertmanager/).
This type create a daemontools-compatible service directory under /service/prometheus.
Daemontools (or something compatible) must be installed (in particular, the command `svc` must be executable).
REQUIRED PARAMETERS
-------------------
@ -27,10 +30,7 @@ storage-path
BOOLEAN PARAMETERS
------------------
with-daemontools
Create a daemontools service directory under /service/prometheus. Default: yes.
Note: If you do not use this, Alertmanager will not be launched, and will not reload config on change.
If you use this, daemontools (or something compatible) must be installed.
None
EXAMPLES
@ -44,6 +44,7 @@ EXAMPLES
__golang_from_vendor --version 1.8.1 # required for prometheus and many exporters
require="__daemontools __golang_from_vendor" __prometheus_alertmanager \
--with-daemontools \
--config "$__manifest/files/alertmanager.yml" \
--storage-path /data/alertmanager \
--listen-address "[::]:$ALERTPORT"

View file

@ -11,12 +11,6 @@ config="$(cat "$__object/parameter/config")"
storage_path="$(cat "$__object/parameter/storage-path")"
listen_address="$(cat "$__object/parameter/listen-address")"
ONCHANGE=""
if [ -f "$__object/parameter/with-daemontools" ]; then
__daemontools_service prometheus --run "setuidgid prometheus $GOBIN/prometheus $REAL_FLAGS"
ONCHANGE="svc -h /service/prometheus"
fi
FLAGS="config.file '$CONF'
storage.path '$storage_path'
web.listen-address '$listen_address'
@ -27,12 +21,12 @@ REAL_FLAGS="$(echo "$FLAGS" | sed -nE 's/^([^#]+).*/ --\1 \\/p')"
__go_get github.com/prometheus/alertmanager/cmd/...
__user prometheus --system
__directory "$storage_path" --owner prometheus
__directory "$CONF_DIR" --owner prometheus
require="__user/prometheus" __directory "$storage_path" --owner prometheus
require="__user/prometheus" __directory "$CONF_DIR" --owner prometheus
__daemontools_service alertmanager --run "setuidgid prometheus $GOBIN/alertmanager $REAL_FLAGS"
require="$require __directory/$storage_path" \
require="$require __directory/$storage_path __user/prometheus" \
__config_file $CONF \
--source $config \
--group prometheus --mode 640 \

View file

@ -10,6 +10,9 @@ DESCRIPTION
-----------
Install and configure Prometheus (https://prometheus.io/).
This type creates a daemontools-compatible service directory under /service/prometheus.
Daemontools (or something compatible) must be installed (in particular, the command `svc` must be executable).
REQUIRED PARAMETERS
-------------------
@ -35,10 +38,7 @@ target-heap-size
BOOLEAN PARAMETERS
------------------
with-daemontools
Create a daemontools service directory under /service/prometheus. Default: yes.
Note: If you do not use this, Prometheus will not be launched, and will not reload config on change.
If you use this, daemontools (or something compatible) must be installed.
None
EXAMPLES
@ -53,6 +53,7 @@ EXAMPLES
__golang_from_vendor --version 1.8.1 # required for prometheus and many exporters
require="__daemontools __golang_from_vendor" __prometheus_server \
--with-daemontools \
--config "$__manifest/files/prometheus.yml" \
--retention-days 14 \
--storage-path /data/prometheus \

View file

@ -16,11 +16,6 @@ rule_files="$(cat "$__object/parameter/rule-files")"
# explorer in kB => convert; by default we go with 1/2 RAM
[ "$target_heap_size" = "auto" ] && target_heap_size=$(($(cat $__global/explorer/memory)*1024/2))
ONCHANGE=""
if [ -f "$__object/parameter/with-daemontools" ]; then
__daemontools_service prometheus --run "setuidgid prometheus $GOBIN/prometheus $REAL_FLAGS"
ONCHANGE="&& svc -h /service/prometheus"
fi
FLAGS="config.file '$CONF'
storage.local.path '$storage_path'
@ -35,23 +30,23 @@ REAL_FLAGS="$(echo "$FLAGS" | sed -nE 's/^([^#]+).*/ --\1 \\/p')"
__go_get github.com/prometheus/prometheus/cmd/...
__user prometheus --system
__directory "$storage_path" --owner prometheus
__directory "$CONF_DIR" --owner prometheus
require="__user/prometheus" __directory "$storage_path" --owner prometheus
require="__user/prometheus" __directory "$CONF_DIR" --owner prometheus
__daemontools_service prometheus --run "setuidgid prometheus $GOBIN/prometheus $REAL_FLAGS"
require="$require __directory/$storage_path" \
require="$require __directory/$storage_path __user/prometheus" \
__config_file $CONF \
--source $config \
--group prometheus --mode 640 \
--onchange "$GOBIN/promtool check-config $CONF $ONCHANGE"
--onchange "$GOBIN/promtool check-config $CONF && svc -h /service/prometheus"
for file in $rule_files; do
dest=$CONF_DIR/$(basename $file)
require="$require __directory/$CONF_DIR" \
require="$require __directory/$CONF_DIR __user/prometheus" \
__config_file "$dest" \
--source "$file" \
--owner prometheus \
--onchange "$GOBIN/promtool check-rules '$dest' $ONCHANGE"
--onchange "$GOBIN/promtool check-rules '$dest' && svc -h /service/prometheus"
done

View file

@ -1 +0,0 @@
with-daemontools