Debianized prototype sources.
authorStanislaw Klekot <dozzie@jarowit.net>
Thu, 18 May 2017 19:15:21 +0000 (21:15 +0200)
committerStanislaw Klekot <dozzie@jarowit.net>
Thu, 18 May 2017 19:15:40 +0000 (21:15 +0200)
It's actually a merge from debianize branch; that one will only have master
merged.

13 files changed:
debian/brookengine.default [new file with mode: 0644]
debian/brookengine.dirs [new file with mode: 0644]
debian/brookengine.docs [new file with mode: 0644]
debian/brookengine.init [new file with mode: 0755]
debian/brookengine.install [new file with mode: 0644]
debian/brookengine.logrotate [new file with mode: 0644]
debian/brookengine.manpages [new file with mode: 0644]
debian/brookengine.postinst [new file with mode: 0755]
debian/changelog [new file with mode: 0644]
debian/compat [new file with mode: 0644]
debian/control [new file with mode: 0644]
debian/rules [new file with mode: 0755]
debian/source/format [new file with mode: 0644]

diff --git a/debian/brookengine.default b/debian/brookengine.default
new file mode 100644 (file)
index 0000000..ee946c9
--- /dev/null
@@ -0,0 +1,11 @@
+# main configuration for daemon
+#BROOKENGINE_CONFIG=/etc/brookengine/brookengine.conf
+#BROOKENGINE_LOG=/var/log/brookengine.log
+
+# path to control socket, necessary for reloading queries
+# should be synchronized with path set in $BROOKENGINE_CONFIG
+#CONTROL_SOCKET=/var/run/brookengine/queries
+
+# which user/group the daemon should run as
+#BROOKENGINE_USER=brookengine
+#BROOKENGINE_GROUP=brookengine
diff --git a/debian/brookengine.dirs b/debian/brookengine.dirs
new file mode 100644 (file)
index 0000000..ca91228
--- /dev/null
@@ -0,0 +1,3 @@
+/etc/brookengine/plugin
+/var/lib/brookengine
+/var/log/brookengine
diff --git a/debian/brookengine.docs b/debian/brookengine.docs
new file mode 100644 (file)
index 0000000..f0f644e
--- /dev/null
@@ -0,0 +1,2 @@
+LICENSE
+README.md
diff --git a/debian/brookengine.init b/debian/brookengine.init
new file mode 100755 (executable)
index 0000000..0bd0113
--- /dev/null
@@ -0,0 +1,170 @@
+#! /bin/sh
+### BEGIN INIT INFO
+# Provides:          brookengine
+# Required-Start:    $network $syslog
+# Required-Stop:     
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: BrookEngine stream processing daemon
+### END INIT INFO
+
+# Do NOT "set -e"
+
+# PATH should only include /usr/* if it runs after the mountnfs.sh script
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
+DESC="BrookEngine stream processing daemon"
+NAME=brookengine
+DAEMON=/usr/sbin/brookengine
+PIDFILE=/var/run/$NAME.pid
+CONTROL_SOCKET=/var/run/brookengine/queries
+SCRIPTNAME=/etc/init.d/$NAME
+
+BROOKENGINE_CONFIG=/etc/brookengine/brookengine.conf
+BROOKENGINE_LOG=/var/log/brookengine.log
+
+BROOKENGINE_USER=brookengine
+BROOKENGINE_GROUP=brookengine
+
+# Exit if the package is not installed
+[ -x "$DAEMON" ] || exit 0
+
+# Read configuration variable file if it is present
+[ -r /etc/default/$NAME ] && . /etc/default/$NAME
+
+# Load the VERBOSE setting and other rcS variables
+. /lib/init/vars.sh
+
+# Define LSB log_* functions.
+# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
+# and status_of_proc is working.
+. /lib/lsb/init-functions
+
+#
+# Function that starts the daemon
+#
+do_start() {
+  # Return
+  #   0 if daemon has been started
+  #   1 if daemon was already running
+  #   2 if daemon could not be started
+
+  if [ ! -e "$BROOKENGINE_CONFIG" ]; then
+    log_failure_msg "$NAME configuration file $BROOKENGINE_CONFIG doesn't exist"
+    return 2
+  fi
+  if [ ! -d ${CONTROL_SOCKET%/*} ]; then
+    mkdir -m 700 -p ${CONTROL_SOCKET%/*}
+    chown $BROOKENGINE_USER:$BROOKENGINE_GROUP ${CONTROL_SOCKET%/*}
+  fi
+
+  # NOTE: `fluentd' should be `${DAEMON##*/}', but for Various Reasons[tm]
+  # it's not
+  start-stop-daemon --start --quiet > /dev/null \
+    --pidfile $PIDFILE \
+    --name fluentd --exec /usr/bin/ruby1.9.1 --test || return 1
+  start-stop-daemon --start --quiet \
+    --pidfile $PIDFILE \
+    --exec $DAEMON -- \
+        --config $BROOKENGINE_CONFIG \
+        --background --pidfile $PIDFILE \
+        ${BROOKENGINE_USER:+--user $BROOKENGINE_USER} \
+        ${BROOKENGINE_GROUP:+--group $BROOKENGINE_GROUP} \
+        ${BROOKENGINE_LOG:+--logfile $BROOKENGINE_LOG} || return 2
+}
+
+#
+# Function that stops the daemon
+#
+do_stop() {
+  # Return
+  #   0 if daemon has been stopped
+  #   1 if daemon was already stopped
+  #   2 if daemon could not be stopped
+  #   other if a failure occurred
+  pid=`cat $PIDFILE 2> /dev/null`
+  # NOTE: `fluentd' should be `${DAEMON##*/}', but for Various Reasons[tm]
+  # it's not
+  start-stop-daemon --stop --quiet \
+    --retry=TERM/30/KILL/5 \
+    --pidfile $PIDFILE --name fluentd
+  RETVAL="$?"
+  [ "$RETVAL" = 2 ] && return 2
+
+  if [ $RETVAL = 0 -a -n "$pid" ]; then
+    # wait for fluentd to terminate
+    while kill -0 $pid 2> /dev/null && sleep 1; do
+      echo -n .
+    done
+  fi
+
+  rm -f $PIDFILE
+  return "$RETVAL"
+}
+
+#
+# Function that reloads query definitions
+#
+do_reload() {
+  #start-stop-daemon --stop --signal HUP --quiet \
+  #  --pidfile $PIDFILE --name ${DAEMON##*/}
+  #return 0
+  $DAEMON reload --socket=$CONTROL_SOCKET
+}
+
+case "$1" in
+  start)
+    log_daemon_msg "Starting $DESC" "$NAME"
+    do_start
+    case "$?" in
+      0|1) log_end_msg 0 ;;
+      2)   log_end_msg 1 ;;
+    esac
+  ;;
+  stop)
+    log_daemon_msg "Stopping $DESC" "$NAME"
+    do_stop
+    case "$?" in
+      0|1) log_end_msg 0 ;;
+      2)   log_end_msg 1 ;;
+    esac
+  ;;
+  status)
+    status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
+  ;;
+  reload|force-reload)
+    log_daemon_msg "Reloading $DESC" "$NAME"
+    do_reload
+    log_end_msg $?
+  ;;
+  configtest)
+    do_configtest
+  ;;
+  restart)
+    log_daemon_msg "Restarting $DESC" "$NAME"
+    if ! do_configtest > /dev/null 2>&1; then
+      log_end_msg 1
+      exit 1
+    fi
+    do_stop
+    case "$?" in
+      0|1)
+        do_start
+        case "$?" in
+          0) log_end_msg 0 ;;
+          1) log_end_msg 1 ;; # Old process is still running
+          *) log_end_msg 1 ;; # Failed to start
+        esac
+      ;;
+      *)
+        # Failed to stop
+        log_end_msg 1
+      ;;
+    esac
+  ;;
+  *)
+    echo "Usage: $SCRIPTNAME {start|stop|status|configtest|restart|reload|force-reload}" >&2
+    exit 3
+  ;;
+esac
+
+:
diff --git a/debian/brookengine.install b/debian/brookengine.install
new file mode 100644 (file)
index 0000000..2bb8c5b
--- /dev/null
@@ -0,0 +1,7 @@
+/etc/brookengine/brookengine.conf.example
+/etc/brookengine/queries.yaml
+/etc/brookengine/queries.logging
+/usr/sbin/brookengine
+/usr/bin/brook
+/usr/lib/brookengine/fluentd/gems
+/usr/lib/brookengine/fluentd/specifications
diff --git a/debian/brookengine.logrotate b/debian/brookengine.logrotate
new file mode 100644 (file)
index 0000000..5a5d556
--- /dev/null
@@ -0,0 +1,10 @@
+/var/log/brookengine.log {
+  missingok
+  notifempty
+  nocreate
+  compress
+  copytruncate
+  weekly
+  size 5M
+  rotate 4
+}
diff --git a/debian/brookengine.manpages b/debian/brookengine.manpages
new file mode 100644 (file)
index 0000000..4eedf9f
--- /dev/null
@@ -0,0 +1,2 @@
+doc/man/brook.1
+doc/man/brookengine.8
diff --git a/debian/brookengine.postinst b/debian/brookengine.postinst
new file mode 100755 (executable)
index 0000000..a3850c2
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+set -e
+
+if [ -z "`getent group brookengine`" ]; then
+  addgroup --quiet --system brookengine
+fi
+if [ -z "`getent passwd brookengine`" ]; then
+  echo -n "  Creating new user brookengine " >&2
+  adduser --quiet --system --home /var/lib/brookengine --shell /bin/false \
+      --ingroup brookengine --disabled-password --disabled-login \
+      --gecos "BrookEngine daemon" brookengine
+  echo "done." >&2
+fi
+
+chown brookengine:brookengine /var/lib/brookengine
+chmod 0700 /var/lib/brookengine
+chown brookengine:brookengine /var/log/brookengine
+
+#DEBHELPER#
diff --git a/debian/changelog b/debian/changelog
new file mode 100644 (file)
index 0000000..c53db3c
--- /dev/null
@@ -0,0 +1,5 @@
+brookengine (0.0.0-1) stable; urgency=low
+
+  * Initial release.
+
+ -- Stanislaw Klekot <dozzie@jarowit.net>  Wed, 10 May 2017 23:59:09 +0200
diff --git a/debian/compat b/debian/compat
new file mode 100644 (file)
index 0000000..7f8f011
--- /dev/null
@@ -0,0 +1 @@
+7
diff --git a/debian/control b/debian/control
new file mode 100644 (file)
index 0000000..de6110e
--- /dev/null
@@ -0,0 +1,19 @@
+Source: brookengine
+Maintainer: Stanislaw Klekot <dozzie@jarowit.net>
+Section: admin
+Priority: optional
+Build-Depends: debhelper (>> 7.0.0), make, python-support,
+ ruby1.9.1 | ruby (>= 1.9.3)
+X-Python-Version: >= 2.6
+
+Package: brookengine
+Architecture: all
+Depends: ${shlibs:Depends}, ${misc:Depends}, ${python:Depends},
+ fluentd, seismometer-toolbox (>= 0.5.0),
+ python-msgpack | msgpack-python
+Description: stream processing engine for monitoring systems
+ BrookEngine is a stream processing engine designed facilitate building
+ monitoring systems. BrookEngine works as a data market, a place for
+ monitoring probes to submit check results and metrics to and for processing
+ clients to receive data from. BrookEngine operates in publish-subscribe
+ model, so any additional tool can be plugged in easily.
diff --git a/debian/rules b/debian/rules
new file mode 100755 (executable)
index 0000000..640f9ea
--- /dev/null
@@ -0,0 +1,24 @@
+#!/usr/bin/make -f
+
+%:
+       dh $@
+
+# TODO: build HTML docs, install HTML docs
+override_dh_auto_build:
+       make all -C fluentd
+       make man -C doc
+
+override_dh_auto_install:
+       mkdir -p $(CURDIR)/debian/tmp/etc/brookengine
+       mkdir -p $(CURDIR)/debian/tmp/usr/bin
+       mkdir -p $(CURDIR)/debian/tmp/usr/sbin
+       install -m 644 examples/brookengine.conf $(CURDIR)/debian/tmp/etc/brookengine/brookengine.conf.example
+       install -m 644 examples/queries.yaml     $(CURDIR)/debian/tmp/etc/brookengine/queries.yaml
+       install -m 644 examples/queries.logging  $(CURDIR)/debian/tmp/etc/brookengine/queries.logging
+       install -m 755 bin/brookengine $(CURDIR)/debian/tmp/usr/sbin/brookengine
+       install -m 755 bin/brook       $(CURDIR)/debian/tmp/usr/bin/brook
+       make install -C fluentd DESTDIR=$(CURDIR)/debian/tmp
+
+override_dh_auto_clean:
+       make clean -C doc
+       make clean -C fluentd
diff --git a/debian/source/format b/debian/source/format
new file mode 100644 (file)
index 0000000..89ae9db
--- /dev/null
@@ -0,0 +1 @@
+3.0 (native)