Permalink
Browse files

[service-ng]Add daylimit for rabbitmq

git shortlog 22b8b6b..c8353f0
Chunjie (1):
      replace old mongo proxy with new one

Yang Yang (2):
      fix marketplace unit test
      Merge "fix marketplace unit test"

andyzh (2):
      [service-ng]Add govendor
      [service-ng]Correct spelling error

Change-Id: Ief042dcc383c4be3d2ab20df070821dbf9efc63f
  • Loading branch information...
1 parent ba20838 commit 37f1b640cb0aa8d63bddef032c7c92cfe3ee50e4 @andyzh andyzh committed Dec 30, 2012
View
@@ -14,11 +14,15 @@ templates:
warden.yml.erb: config/warden.yml
warden_service_ctl: bin/warden_service_ctl
+ daylimit_ctl: bin/daylimit_ctl
+ daylimit.yml.erb: config/daylimit.yml
+
packages:
- common
- erlang
- rabbitmq-2.4
- rabbitmq-2.8
+ - daylimit
- ruby
- sqlite
- rabbit_node_ng
@@ -0,0 +1,15 @@
+---
+<%
+service = "rabbit"
+plan_enabled = properties.service_plans && properties.service_plans.send(service.to_sym)
+plan = properties.plan || "free"
+plan_conf = plan_enabled && properties.service_plans.send(service.to_sym).send(plan.to_sym).configuration
+node = properties.rabbit_node
+%>
+limitwindow: <%= plan_enabled && plan_conf.bandwidth_quotas && plan_conf.bandwidth_quotas.time_window || 86400 %>
+limitsize: <%= (plan_enabled && plan_conf.bandwidth_quotas && plan_conf.bandwidth_quotas.per_day || 1) * 1024 * 1024 %>
+logfile: /var/vcap/sys/log/daylimit/daylimit.log
+fetchinterval: 2
+blockrate: 600
+unblockrate: <%= ((plan_enabled && plan_conf.bandwidth_quotas && plan_conf.bandwidth_quotas.per_second || 0.09) * 1024 * 1024).to_i %>
+wardenbin: /var/vcap/packages/rabbit_node_ng/warden/bin/warden
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+DAYLIMIT_NG_BIN=/var/vcap/packages/daylimit/daylimit/bin/daylimit
+RUN_DIR=/var/vcap/sys/run/daylimit
+JOB_DIR=/var/vcap/jobs/rabbit_node_ng
+LOG_DIR=/var/vcap/sys/log/daylimit
+PIDFILE=${RUN_DIR}/daylimit.pid
+
+source /var/vcap/packages/common/utils.sh
+export PATH=/var/vcap/packages/ruby/bin:$PATH
+# Used in warden client
+export HOME=/var/vcap
+
+case $1 in
+
+ start)
+ mkdir -p ${RUN_DIR}
+ mkdir -p ${LOG_DIR}
+ echo $$ > ${PIDFILE}
+ exec ${DAYLIMIT_NG_BIN} -c ${JOB_DIR}/config/daylimit.yml >> ${LOG_DIR}/daylimit.stdout.log 2>>${LOG_DIR}/daylimit.stderr.log
+ ;;
+
+ stop)
+ kill_and_wait $PIDFILE
+ ;;
+
+ *)
+ echo "Usage: daylimit_ctl {start|stop}"
+ ;;
+
+esac
@@ -11,3 +11,10 @@ check process rabbit_node
stop program "/var/vcap/jobs/rabbit_node_ng/bin/rabbit_node_ctl stop"
group vcap
depends on warden
+
+check process daylimit
+ with pidfile /var/vcap/sys/run/daylimit/daylimit.pid
+ start program "/var/vcap/jobs/rabbit_node_ng/bin/daylimit_ctl start"
+ stop program "/var/vcap/jobs/rabbit_node_ng/bin/daylimit_ctl stop"
+ group vcap
+ depends on warden
@@ -0,0 +1,11 @@
+# abort script on any command that exit with a non zero value
+set -e
+
+mkdir -p ${BOSH_INSTALL_TARGET}/daylimit/src
+cp -a services/tools/daylimit ${BOSH_INSTALL_TARGET}/daylimit/src/
+cp -a services/govendor ${BOSH_INSTALL_TARGET}/
+export GOROOT=`readlink -nf /var/vcap/packages/golang`
+export GOPATH=`readlink -nf ${BOSH_INSTALL_TARGET}/daylimit`:`readlink -nf ${BOSH_INSTALL_TARGET}/govendor`
+GOLANG_PATH=`readlink -nf /var/vcap/packages/golang`
+export PATH=$GOLANG_PATH/bin:$PATH
+go install daylimit
View
@@ -0,0 +1,7 @@
+---
+name: daylimit
+dependencies:
+- golang
+files:
+- services/tools/daylimit/**/*
+- services/govendor/**/*

0 comments on commit 37f1b64

Please sign in to comment.