Browse files

bat-light a more lightweight job/package

Change-Id: Ib4bf1225a117a0e3b9f5c8d8043bba227e95d266
  • Loading branch information...
1 parent 5137fb3 commit 055598b9a81dffd1e2bfa7999a1ccf02393345a2 @pmenglund pmenglund committed Oct 15, 2012
View
6 jobs/batlight/monit
@@ -0,0 +1,6 @@
+check process batlight
+ with pidfile /var/vcap/sys/run/batlight/batlight.pid
+ start program "/var/vcap/jobs/batlight/bin/batlight_ctl start"
+ stop program "/var/vcap/jobs/batlight/bin/batlight_ctl stop"
+ group vcap
+
View
9 jobs/batlight/spec
@@ -0,0 +1,9 @@
+---
+name: batlight
+
+templates:
+ batlight_ctl: bin/batlight_ctl
+ drain: bin/drain
+
+packages:
+ - batlight
View
43 jobs/batlight/templates/batlight_ctl
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+JOB=batlight
+BASE=/var/vcap
+
+export PATH=$BASE/packages/ruby/bin:$PATH
+export BUNDLE_GEMFILE=$BASE/packages/$JOB/Gemfile
+
+RUN_DIR=$BASE/sys/run/$JOB
+LOG_DIR=$BASE/sys/log/$JOB
+BIN_DIR=$BASE/packages/$JOB/bin
+STORE_DIR=$BASE/store/$JOB
+PIDFILE=$RUN_DIR/$JOB.pid
+
+RUNAS=vcap
+
+case $1 in
+
+ start)
+ mkdir -p $RUN_DIR $LOG_DIR $STORE_DIR
+ chown -R $RUNAS:$RUNAS $RUN_DIR $LOG_DIR $STORE_DIR
+
+ echo $$ > $PIDFILE
+
+ exec chpst -u $RUNAS:$RUNAS \
+ $BIN_DIR/batlight <%= spec.index %> \
+ >>$LOG_DIR/$JOB.stdout.log \
+ 2>>$LOG_DIR/$JOB.stderr.log
+ ;;
+
+ stop)
+ PID=$(head -1 $PIDFILE)
+ kill $PID
+ while [ -e /proc/$PID ]; do sleep 0.1; done
+ rm -f $PIDFILE
+ ;;
+
+ *)
+
+ echo "Usage: $JOB_ctl {start|stop}" ;;
+esac
+exit 0
+
View
12 jobs/batlight/templates/drain
@@ -0,0 +1,12 @@
+#!/bin/sh
+#
+# fake drain script
+
+FLAG=/tmp/drain
+
+if [ -f $FLAG ]; then
+ echo "0"
+else
+ touch $FLAG
+ echo "2"
+fi
View
5 packages/batlight/packaging
@@ -0,0 +1,5 @@
+# abort script on any command that exit with a non zero value
+set -e
+
+cp -a batlight/* ${BOSH_INSTALL_TARGET}
+
View
5 packages/batlight/spec
@@ -0,0 +1,5 @@
+---
+name: batlight
+
+files:
+ - batlight/**/*
View
9 src/batlight/bin/batlight
@@ -0,0 +1,9 @@
+#!/bin/sh
+#
+
+FOREVAH=true
+
+while [ $FOREVAH ]; do
+ sleep 1
+done
+

0 comments on commit 055598b

Please sign in to comment.