Created
May 20, 2013 19:14
-
-
Save choang/5614689 to your computer and use it in GitHub Desktop.
OpenTSDB init script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
. /etc/init.d/functions | |
PIDFILE=/var/run/tsd.pid | |
LOCKFILE=/var/lock/subsys/tsd | |
TSD_CONF=/usr/local/etc/tsd.conf | |
TSDB_BIN=/usr/local/bin/tsdb | |
TSD_LOGDIR=/var/tmp/tsd | |
export TSDB_HOME=/usr/local/share/opentsdb | |
export JVMARGS="-Xmx16G -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9990 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false" | |
start() { | |
echo -n "Starting TimeSeries Daemon: " | |
if [ -f $PIDFILE ]; then | |
PID=`cat $PIDFILE` | |
echo TSD already running: $PID | |
exit 2; | |
fi | |
daemon $TSDB_BIN tsd --config=$TSD_CONF >> $TSD_LOGDIR/tsd.log & 2>&1 | |
sleep 1 | |
test -e $PIDFILE && checkpid $(cat $PIDFILE) | |
RETVAL=$? | |
if [ "$RETVAL" == "0" ]; then | |
echo_success | |
echo | |
else | |
echo_failure | |
echo | |
echo "Could not start TSD." 1>&2 | |
exit 2 | |
fi | |
[ $RETVAL -eq 0 ] && touch $LOCKFILE | |
return $RETVAL | |
} | |
stop() { | |
echo -n "Shutting down TimeSeries Daemon: " | |
killproc -p $PIDFILE TSDMain | |
echo_success | |
echo | |
rm -f $LOCKFILE | |
rm -f $PIDFILE | |
return 0 | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
status) | |
status -p $PIDFILE tsd | |
;; | |
restart) | |
stop | |
sleep 1 | |
start | |
;; | |
*) | |
echo "Usage: {start|stop|status|restart" | |
exit 1 | |
;; | |
esac | |
exit $? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/tsdb.in b/tsdb.in | |
index 45e5cb2..1e1fc35 100644 | |
--- a/tsdb.in | |
+++ b/tsdb.in | |
@@ -8,12 +8,7 @@ mydir=`dirname "$0"` | |
# or pkgdatadir is set: we've been installed, we respect that. | |
abs_srcdir='@abs_srcdir@' | |
abs_builddir='@abs_builddir@' | |
- | |
-if [ -z $TSDB_HOME ]; then | |
- echo >&2 "$me: TSDB_HOME is not set" | |
- exit 2 | |
-fi | |
-pkgdatadir=$TSDB_HOME | |
+pkgdatadir='@pkgdatadir@' | |
# Either we've been installed and pkgdatadir exists, or we haven't been | |
# installed and abs_srcdir / abs_builddir aren't empty. | |
test -d "$pkgdatadir" || test -n "$abs_srcdir$abs_builddir" || { | |
@@ -73,8 +68,6 @@ case $1 in | |
;; | |
(tsd) | |
MAINCLASS=TSDMain | |
- PIDFILE=/var/run/tsd.pid | |
- echo $$ > $PIDFILE | |
;; | |
(scan) | |
MAINCLASS=DumpSeries |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Baseline for my tsdb.in change was OpenTSDB/opentsdb@7cb3fa2