Permalink
Browse files

bring echo service bosh package

Change-Id: Id098831b97e26281eec29ebc7c288f9f0872e3dc
  • Loading branch information...
1 parent ed1aa37 commit c05e5956b09765d69b0d5537acb40ffaa7a9218f @figof figof committed with figof Aug 22, 2012
View
56 README
@@ -0,0 +1,56 @@
+Copyright (c) 2009-2011 VMware, Inc.
+
+== What is Cloud Foundry?
+
+Cloud Foundry is an open platform-as-a-service (PaaS). The system supports
+multiple frameworks, multiple application infrastructure services and
+deployment to multiple clouds.
+
+== What is this component?
+
+This repo contains the sample BOSH package and release for a sample Cloud Foundry service:
+echo service (https://github.com/cloudfoundry/vcap-services/tree/master/echo)
+the section below will walk you through how to deploy echo service into Cloud Foundry
+
+== How to deploy echo service with BOSH package and release?
+
+1. git clone cf-release repo (https://github.com/cloudfoundry/cf-release)
+2. git clone vcap-services-sample-release repo (https://github.com/cloudfoundry/vcap-services-sample-release)
+3. cp -r vcap-services-sample-release/jobs/* cf-release/jobs/
+ cp -r vcap-services-sample-release/packages/* cf-release/packages/
+4. append the content of vcap-services-sample-release/config/blobs_echo.yml to cf-release/config/blobs.yml
+5. add 'echo' into 'builtin_services' section of cloud controller configuration file - see https://github.com/cloudfoundry/cf-release/blob/master/jobs/cloud_controller/templates/cloud_controller.yml.erb#L163
+6. bosh create release and then bosh upload release
+7. in your BOSH deployment manifest, add below section under 'jobs', for example insert into https://github.com/cloudfoundry/oss-docs/blob/master/bosh/samples/cloudfoundry.yml#L324
+
+ - name: echo_node
+ template: echo_node
+ instances: 1
+ resource_pool: infrastructure
+ persistent_disk: 128
+ networks:
+ - name: default
+ static_ips:
+ - 192.0.2.90
+
+ - name: echo_gateway
+ template: echo_gateway
+ instances: 1
+ resource_pool: infrastructure
+ networks:
+ - name: default
+
+ and add gateway token under 'properties', for example insert into https://github.com/cloudfoundry/oss-docs/blob/master/bosh/samples/cloudfoundry.yml#L475
+
+ echo_gateway:
+ token: changeme
+ echoserver:
+ port: 8080
+
+ and change resource pool size if necessary, see https://github.com/cloudfoundry/oss-docs/blob/master/bosh/samples/cloudfoundry.yml#L55
+
+8. bosh deploy
+
+== License
+
+Cloud Foundry uses the Apache 2 license. See LICENSE for details.
View
@@ -0,0 +1,4 @@
+echoserver/EchoServer-0.1.0.jar:
+ object_id: eyJvaWQiOiI0ZTRlNzhiY2E2MWUxMjEyMDRlNGU4NmVlYmU1OTEwNGZlN2Qw%0AMmQ3MWI2ZCIsInNpZyI6IlFpRk1Hc3NzUHRYc3hGZW9VQ1BtZGtXZy9sND0i%0AfQ==%0A
+ sha: 0de6428519388b19b6ed2316fa77849f306c5bb7
+ size: 4164
View
@@ -0,0 +1,5 @@
+check process echo_gateway
+ with pidfile /var/vcap/sys/run/echo_gateway/echo_gateway.pid
+ start program "/var/vcap/jobs/echo_gateway/bin/echo_gateway_ctl start"
+ stop program "/var/vcap/jobs/echo_gateway/bin/echo_gateway_ctl stop"
+ group vcap
View
@@ -0,0 +1,14 @@
+---
+name: echo_gateway
+
+templates:
+ echo_gateway_ctl: bin/echo_gateway_ctl
+ echo_gateway.yml.erb: config/echo_gateway.yml
+ syslog_forwarder.conf.erb: config/syslog_forwarder.conf
+
+packages:
+- common
+- echo_gateway
+- ruby
+- sqlite
+- syslog_aggregator
@@ -0,0 +1,21 @@
+---
+cloud_controller_uri: <%= properties.cc.srv_api_uri %>
+mbus: nats://<%= properties.nats.user %>:<%= properties.nats.password %>@<%= properties.nats.address %>:<%= properties.nats.port %>
+index: <%= spec.index %>
+service:
+ name: echo
+ version: "1.0"
+ description: 'Echo Service'
+ plans: ['free']
+ tags: ['echo', 'echo-1.0', 'demo', 'echobased']
+ supported_versions: ['1.0']
+ version_aliases:
+ 'current': '1.0'
+<% if properties.echo_gateway.ip_route %>
+ip_route: <%= properties.echo_gateway.ip_route %>
+<% end %>
+token: <%= properties.echo_gateway.token %>
+logging:
+ level: debug
+pid: /var/vcap/sys/run/echo_gateway/echo_gateway.pid
+node_timeout: 2
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+export PATH=$PATH:/var/vcap/packages/ruby/bin
+
+RUN_DIR=/var/vcap/sys/run/echo_gateway
+LOG_DIR=/var/vcap/sys/log/echo_gateway
+PIDFILE=$RUN_DIR/echo_gateway.pid
+JOB_DIR=/var/vcap/jobs/echo_gateway
+
+source /var/vcap/packages/common/utils.sh
+
+case $1 in
+
+ start)
+ pid_guard $PIDFILE "Echo gateway"
+
+ mkdir -p $RUN_DIR
+ mkdir -p $LOG_DIR
+
+ echo $$ > $PIDFILE
+
+ <% if properties.syslog_aggregator %>
+ /var/vcap/packages/syslog_aggregator/setup_syslog_forwarder.sh $JOB_DIR/config
+ <% end %>
+
+ exec /var/vcap/packages/echo_gateway/services/echo/bin/echo_gateway \
+ -c $JOB_DIR/config/echo_gateway.yml \
+ >>$LOG_DIR/echo_gateway.stdout.log \
+ 2>>$LOG_DIR/echo_gateway.stderr.log
+
+ ;;
+
+ stop)
+ kill_and_wait $PIDFILE
+
+ ;;
+
+ *)
+ echo "Usage: echo_gateway_ctl {start|stop}"
+
+ ;;
+
+esac
@@ -0,0 +1,25 @@
+<% if properties.syslog_aggregator %>
+$ModLoad imuxsock # local message reception (rsyslog uses a datagram socket)
+$MaxMessageSize 4k # default is 2k
+$WorkDirectory /var/vcap/sys/rsyslog/buffered # where messages should be buffered on disk
+
+# Forward vcap messages to the aggregator
+#
+$ActionResumeRetryCount -1 # Try until the server becomes available
+$ActionQueueType LinkedList # Allocate on-demand
+$ActionQueueFileName agg_backlog # Spill to disk if queue is full
+$ActionQueueMaxDiskSpace 32m # Max size for disk queue
+$ActionQueueLowWaterMark 2000 # Num messages. Assuming avg size of 512B, this is 1MiB.
+$ActionQueueHighWaterMark 8000 # Num messages. Assuming avg size of 512B, this is 4MiB. (If this is reached, messages will spill to disk until the low watermark is reached).
+$ActionQueueTimeoutEnqueue 0 # Discard messages if the queue + disk is full
+$ActionQueueSaveOnShutdown on # Save in-memory data to disk if rsyslog shuts down
+:programname, startswith, "vcap." @@<%= properties.syslog_aggregator.address %>:<%= properties.syslog_aggregator.port %>
+
+# Log vcap messages locally, too
+#$template VcapComponentLogFile, "/var/log/%programname:6:$%/%programname:6:$%.log"
+#$template VcapComponentLogFormat, "%timegenerated% %syslogseverity-text% -- %msg%\n"
+#:programname, startswith, "vcap." -?VcapComponentLogFile;VcapComponentLogFormat
+
+# Prevent them from reaching anywhere else
+:programname, startswith, "vcap." ~
+<% end %>
View
@@ -0,0 +1,12 @@
+check process echoserver
+ with pidfile /var/vcap/sys/run/echoserver/echoserver.pid
+ start program "/var/vcap/jobs/echo_node/bin/echoserver_ctl start"
+ stop program "/var/vcap/jobs/echo_node/bin/echoserver_ctl stop"
+ group vcap
+
+check process echo_node
+ with pidfile /var/vcap/sys/run/echo_node/echo_node.pid
+ start program "/var/vcap/jobs/echo_node/bin/echo_node_ctl start"
+ stop program "/var/vcap/jobs/echo_node/bin/echo_node_ctl stop"
+ depends on echoserver
+ group vcap
View
@@ -0,0 +1,17 @@
+---
+name: echo_node
+
+templates:
+ echoserver_ctl: bin/echoserver_ctl
+ echo_node_ctl: bin/echo_node_ctl
+ echo_node.yml.erb: config/echo_node.yml
+ syslog_forwarder.conf.erb: config/syslog_forwarder.conf
+
+packages:
+- common
+- dea_jvm
+- echoserver
+- echo_node
+- ruby
+- sqlite
+- syslog_aggregator
@@ -0,0 +1,18 @@
+---
+supported_versions: ['1.0']
+default_version: '1.0'
+capacity: <%= 200 %>
+plan: free
+local_db: sqlite3:/var/vcap/store/echo_node.db
+mbus: nats://<%= properties.nats.user %>:<%= properties.nats.password %>@<%= properties.nats.address %>:<%= properties.nats.port %>
+index: <%= spec.index %>
+base_dir: /var/vcap/store/echo/
+logging:
+ file: /var/vcap/sys/log/echo_node/echo_node.log
+ level: debug
+ <% if properties.syslog_aggregator %>
+ syslog: vcap.echo_node
+ <% end %>
+pid: /var/vcap/sys/run/echo_node/echo_node.pid
+node_id: <%= "echo_node_#{spec.index.to_i + 1}" %>
+port: <%= properties.echoserver && properties.echoserver.port || 8080 %>
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+export PATH=$PATH:/var/vcap/packages/ruby/bin
+
+RUN_DIR=/var/vcap/sys/run/echo_node
+LOG_DIR=/var/vcap/sys/log/echo_node
+PIDFILE=$RUN_DIR/echo_node.pid
+JOB_DIR=/var/vcap/jobs/echo_node
+
+source /var/vcap/packages/common/utils.sh
+
+case $1 in
+
+ start)
+ pid_guard $PIDFILE "Echo node"
+
+ mkdir -p $RUN_DIR
+ mkdir -p $LOG_DIR
+
+ echo $$ > $PIDFILE
+
+ <% if properties.syslog_aggregator %>
+ /var/vcap/packages/syslog_aggregator/setup_syslog_forwarder.sh $JOB_DIR/config
+ <% end %>
+
+ exec /var/vcap/packages/echo_node/services/echo/bin/echo_node \
+ -c $JOB_DIR/config/echo_node.yml \
+ >>$LOG_DIR/echo_node.stdout.log \
+ 2>>$LOG_DIR/echo_node.stderr.log
+
+ ;;
+
+ stop)
+ kill_and_wait $PIDFILE
+
+ ;;
+
+ *)
+ echo "Usage: echo_node_ctl {start|stop}"
+
+ ;;
+
+esac
@@ -0,0 +1,40 @@
+#!/bin/bash -e
+export JAVA_HOME=/var/vcap/packages/dea_jvm
+export PATH=$PATH:/var/vcap/packages/dea_jvm/bin
+
+BIN_DIR=/var/vcap/jobs/echoserver/bin
+RUN_DIR=/var/vcap/sys/run/echoserver
+LOG_DIR=/var/vcap/sys/log/echoserver
+PIDFILE=$RUN_DIR/echoserver.pid
+
+source /var/vcap/packages/common/utils.sh
+
+case $1 in
+
+ start)
+ pid_guard $PIDFILE "EchoServer"
+
+ mkdir -p $RUN_DIR
+ mkdir -p $LOG_DIR
+ echo $$ > $PIDFILE
+
+ cd /var/vcap/packages/echoserver/
+ exec java \
+ -jar EchoServer-0.1.0.jar \
+ -port <%= properties.echoserver && properties.echoserver.port || 8080 %> \
+ >>$LOG_DIR/echoserver.stdout.log \
+ 2>>$LOG_DIR/echoserver.stderr.log
+
+ ;;
+
+ stop)
+ kill_and_wait $PIDFILE
+
+ ;;
+
+ *)
+ echo "Usage: echoserver_ctl {start|stop}"
+
+ ;;
+
+esac
@@ -0,0 +1,25 @@
+<% if properties.syslog_aggregator %>
+$ModLoad imuxsock # local message reception (rsyslog uses a datagram socket)
+$MaxMessageSize 4k # default is 2k
+$WorkDirectory /var/vcap/sys/rsyslog/buffered # where messages should be buffered on disk
+
+# Forward vcap messages to the aggregator
+#
+$ActionResumeRetryCount -1 # Try until the server becomes available
+$ActionQueueType LinkedList # Allocate on-demand
+$ActionQueueFileName agg_backlog # Spill to disk if queue is full
+$ActionQueueMaxDiskSpace 32m # Max size for disk queue
+$ActionQueueLowWaterMark 2000 # Num messages. Assuming avg size of 512B, this is 1MiB.
+$ActionQueueHighWaterMark 8000 # Num messages. Assuming avg size of 512B, this is 4MiB. (If this is reached, messages will spill to disk until the low watermark is reached).
+$ActionQueueTimeoutEnqueue 0 # Discard messages if the queue + disk is full
+$ActionQueueSaveOnShutdown on # Save in-memory data to disk if rsyslog shuts down
+:programname, startswith, "vcap." @@<%= properties.syslog_aggregator.address %>:<%= properties.syslog_aggregator.port %>
+
+# Log vcap messages locally, too
+#$template VcapComponentLogFile, "/var/log/%programname:6:$%/%programname:6:$%.log"
+#$template VcapComponentLogFormat, "%timegenerated% %syslogseverity-text% -- %msg%\n"
+#:programname, startswith, "vcap." -?VcapComponentLogFile;VcapComponentLogFormat
+
+# Prevent them from reaching anywhere else
+:programname, startswith, "vcap." ~
+<% end %>
@@ -0,0 +1,10 @@
+set -e
+
+cp -a * ${BOSH_INSTALL_TARGET}
+
+(
+ cd ${BOSH_INSTALL_TARGET}/services/echo
+ bundle_cmd=/var/vcap/packages/ruby/bin/bundle
+ $bundle_cmd config build.do_sqlite3 --with-sqlite3-dir=/var/vcap/packages/sqlite
+ $bundle_cmd install --local --deployment --without=development test
+)
@@ -0,0 +1,4 @@
+set -e
+
+cd ${BUILD_DIR}
+pkg_utils/vendor.sh services/echo
@@ -0,0 +1,8 @@
+---
+name: echo_gateway
+dependencies:
+- sqlite
+- ruby
+files:
+- services/echo/**/*
+- pkg_utils/*
@@ -0,0 +1,10 @@
+set -e
+
+cp -a * ${BOSH_INSTALL_TARGET}
+
+(
+ cd ${BOSH_INSTALL_TARGET}/services/echo
+ bundle_cmd=/var/vcap/packages/ruby/bin/bundle
+ $bundle_cmd config build.do_sqlite3 --with-sqlite3-dir=/var/vcap/packages/sqlite
+ $bundle_cmd install --local --deployment --without=development test
+)
@@ -0,0 +1,4 @@
+set -e
+
+cd ${BUILD_DIR}
+pkg_utils/vendor.sh services/echo
View
@@ -0,0 +1,8 @@
+---
+name: echo_node
+dependencies:
+- sqlite
+- ruby
+files:
+- services/echo/**/*
+- pkg_utils/*
@@ -0,0 +1,3 @@
+set -e
+
+cp echoserver/EchoServer-0.1.0.jar ${BOSH_INSTALL_TARGET}
View
@@ -0,0 +1,4 @@
+---
+name: echoserver
+files:
+- echoserver/EchoServer-0.1.0.jar

0 comments on commit c05e595

Please sign in to comment.