Actually run datahopper on skiamonitor
BUG=skia:
Review URL: https://codereview.chromium.org/723223002
diff --git a/datahopper/Makefile b/datahopper/Makefile
new file mode 100644
index 0000000..eac5f1f
--- /dev/null
+++ b/datahopper/Makefile
@@ -0,0 +1,5 @@
+default:
+ go install -v ./go/datahopper
+
+release:
+ ./build_release
diff --git a/datahopper/build_release b/datahopper/build_release
new file mode 100755
index 0000000..1678e4b
--- /dev/null
+++ b/datahopper/build_release
@@ -0,0 +1,17 @@
+#!/bin/bash
+# Builds and uploads a debian package for datahopper.
+APPNAME=datahopper
+DESCRIPTION="Program which ingests data into InfluxDB and MySQL."
+
+# Copy files into the right locations in ${ROOT}.
+copy_release_files()
+{
+INSTALL="sudo install -D --verbose --backup=none --group=root --owner=root"
+INSTALL_DIR="sudo install -d --verbose --backup=none --group=root --owner=root"
+${INSTALL} --mode=755 -T ${GOPATH}/bin/datahopper ${ROOT}/usr/local/bin/datahopper
+${INSTALL} --mode=666 -T ./sys/monit ${ROOT}/etc/monit/conf.d/datahopper
+${INSTALL} --mode=755 -T ./sys/init ${ROOT}/etc/init.d/datahopper
+${INSTALL_DIR} --mode=777 ${ROOT}/mnt/pd0/datahopper_scratch
+}
+
+source ../bash/release.sh
diff --git a/monitoring/go/autoroll_ingest/autoroll.go b/datahopper/go/autoroll_ingest/autoroll.go
similarity index 100%
rename from monitoring/go/autoroll_ingest/autoroll.go
rename to datahopper/go/autoroll_ingest/autoroll.go
diff --git a/monitoring/go/datahopper/main.go b/datahopper/go/datahopper/main.go
similarity index 97%
rename from monitoring/go/datahopper/main.go
rename to datahopper/go/datahopper/main.go
index ee56521..101db8e 100644
--- a/monitoring/go/datahopper/main.go
+++ b/datahopper/go/datahopper/main.go
@@ -11,12 +11,12 @@
"github.com/golang/glog"
influxdb "github.com/influxdb/influxdb/client"
+ "skia.googlesource.com/buildbot.git/datahopper/go/autoroll_ingest"
"skia.googlesource.com/buildbot.git/go/buildbot"
"skia.googlesource.com/buildbot.git/go/common"
"skia.googlesource.com/buildbot.git/go/database"
"skia.googlesource.com/buildbot.git/go/gitinfo"
"skia.googlesource.com/buildbot.git/go/metadata"
- "skia.googlesource.com/buildbot.git/monitoring/go/autoroll_ingest"
)
const (
diff --git a/datahopper/sys/init b/datahopper/sys/init
new file mode 100644
index 0000000..2b10dce
--- /dev/null
+++ b/datahopper/sys/init
@@ -0,0 +1,159 @@
+#! /bin/sh
+### BEGIN INIT INFO
+# Provides: logserver
+# Required-Start: $remote_fs $syslog
+# Required-Stop: $remote_fs $syslog
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Start datahopper.
+# Description: Loads data into databases.
+### END INIT INFO
+
+# Author: Joe Gregorio <jcgregorio@google.com>
+#
+# Copied from /etc/init.d/skeleton and modified only the following
+# environment variables and updated the start-stop-daemon calls
+# in do_start() to add --make-pidfile, --background, and --chuid.
+
+# 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="Loads data into databases."
+NAME=datahopper
+DAEMON=/usr/local/bin/$NAME
+DAEMON_ARGS="-use_metadata=true -influxdb_host=localhost:10117 -influxdb_database=graphite --log_dir=/tmp/glog --carbon=localhost:2003 --workdir=/mnt/pd0/datahopper_scratch"
+PIDFILE=/var/run/$NAME.pid
+SCRIPTNAME=/etc/init.d/$NAME
+
+# 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/service
+#
+do_start()
+{
+ # Return
+ # 0 if daemon has been started
+ # 1 if daemon was already running
+ # 2 if daemon could not be started
+ start-stop-daemon --start --pidfile $PIDFILE --exec $DAEMON --make-pidfile --background --chuid default --test > /dev/null \
+ || return 1
+ start-stop-daemon --start --pidfile $PIDFILE --exec $DAEMON --make-pidfile --background --chuid default --exec $DAEMON -- \
+ $DAEMON_ARGS \
+ || return 2
+ # Add code here, if necessary, that waits for the process to be ready
+ # to handle requests from services started subsequently which depend
+ # on this one. As a last resort, sleep for some time.
+}
+
+#
+# Function that stops the daemon/service
+#
+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
+ start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
+ RETVAL="$?"
+ [ "$RETVAL" = 2 ] && return 2
+ # Wait for children to finish too if this is a daemon that forks
+ # and if the daemon is only ever run from this initscript.
+ # If the above conditions are not satisfied then add some other code
+ # that waits for the process to drop all resources that could be
+ # needed by services started subsequently. A last resort is to
+ # sleep for some time.
+ start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
+ [ "$?" = 2 ] && return 2
+ # Many daemons don't delete their pidfiles when they exit.
+ rm -f $PIDFILE
+ return "$RETVAL"
+}
+
+#
+# Function that sends a SIGHUP to the daemon/service
+#
+do_reload() {
+ #
+ # If the daemon can reload its configuration without
+ # restarting (for example, when it is sent a SIGHUP),
+ # then implement that here.
+ #
+ start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
+ return 0
+}
+
+case "$1" in
+ start)
+ [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
+ do_start
+ case "$?" in
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+ esac
+ ;;
+ stop)
+ [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
+ do_stop
+ case "$?" in
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+ esac
+ ;;
+ status)
+ status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
+ ;;
+ #reload|force-reload)
+ #
+ # If do_reload() is not implemented then leave this commented out
+ # and leave 'force-reload' as an alias for 'restart'.
+ #
+ #log_daemon_msg "Reloading $DESC" "$NAME"
+ #do_reload
+ #log_end_msg $?
+ #;;
+ restart|force-reload)
+ #
+ # If the "reload" option is implemented then remove the
+ # 'force-reload' alias
+ #
+ log_daemon_msg "Restarting $DESC" "$NAME"
+ 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|restart|reload|force-reload}" >&2
+ echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
+ exit 3
+ ;;
+esac
+
+:
diff --git a/datahopper/sys/monit b/datahopper/sys/monit
new file mode 100644
index 0000000..2f5ed9a
--- /dev/null
+++ b/datahopper/sys/monit
@@ -0,0 +1,13 @@
+check process datahopper with pidfile /var/run/datahopper.pid
+ start program = "/etc/init.d/datahopper start"
+ stop program = "/etc/init.d/datahopper stop"
+ depends on datahopper_init
+ depends on datahopper_exe
+
+check file datahopper_init
+ with path /etc/init.d/datahopper
+ if changed timestamp then restart
+
+check file datahopper_exe
+ with path /usr/local/bin/datahopper
+ if changed timestamp then restart
diff --git a/monitoring/Makefile b/monitoring/Makefile
index c3e8cb2..f4c3821 100644
--- a/monitoring/Makefile
+++ b/monitoring/Makefile
@@ -5,10 +5,7 @@
alertserver: js skiaversion
go install -v ./go/alertserver
-datahopper:
- go install -v ./go/datahopper
-
-default: alertserver datahopper
+default: alertserver
testgo: skiaversion
go test ./go/... -v
diff --git a/push/skiapush.conf b/push/skiapush.conf
index 27e8484..13f7bf2 100644
--- a/push/skiapush.conf
+++ b/push/skiapush.conf
@@ -22,6 +22,7 @@
[servers.skia-monitoring]
appNames = [
+ "datahopper",
"grains",
"logserver",
"pull",