Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge "Add gorouter job"

  • Loading branch information...
commit dd6dec9c9d6ae24f156f7e200e0c8d278a6c79fd 2 parents 6f5c4db + 8f355ce
Pieter Noordhuis authored Gerrit Code Review committed
View
3  .gitmodules
@@ -40,3 +40,6 @@
[submodule "src/tests"]
path = src/tests
url = git@github.com:cloudfoundry/vcap-yeti.git
+[submodule "src/gorouter"]
+ path = src/gorouter
+ url = git@github.com:cloudfoundry/gorouter.git
View
4 config/blobs.yml
@@ -687,3 +687,7 @@ ruby/bundler-1.2.1.gem:
object_id: eyJvaWQiOiI0ZTRlNzhiY2EzMWUxMjEyMDRlNGU4NmVlMzk2OTIwNTBhMTYy%0ANTJmMDUyZiIsInNpZyI6InZYOFl0dktMN3k5NWNHWTZnbnpVcFpHY2tUMD0i%0AfQ==%0A
sha: 0cbe6ad7a41f064d6c11c1058465fffb1bd58069
size: 226816
+misc/libcap2-bin_1%3a2.17-2ubuntu1_amd64.deb:
+ object_id: eyJvaWQiOiI0ZTRlNzhiY2EzMWUxMjEyMDRlNGU4NmVlMzk2OTIwNTEwYWI4%0AYWNhMWVlMCIsInNpZyI6InFQNXdkVy92Qnk5cmFRNExaRHNzcnFPVmJYST0i%0AfQ==%0A
+ sha: 3b4ac577bfe581a0f687ece942379edefd2ec3c6
+ size: 22076
View
5 jobs/gorouter/monit
@@ -0,0 +1,5 @@
+check process gorouter
+ with pidfile /var/vcap/sys/run/gorouter/gorouter.pid
+ start program "/var/vcap/jobs/gorouter/bin/gorouter start"
+ stop program "/var/vcap/jobs/gorouter/bin/gorouter stop"
+ group vcap
View
11 jobs/gorouter/spec
@@ -0,0 +1,11 @@
+---
+name: gorouter
+templates:
+ gorouter.erb: bin/gorouter
+ gorouter.yml.erb: config/gorouter.yml
+ syslog_forwarder.conf.erb: config/syslog_forwarder.conf
+packages:
+- common
+- golang
+- gorouter
+- syslog_aggregator
View
80 jobs/gorouter/templates/gorouter.erb
@@ -0,0 +1,80 @@
+#!/bin/bash
+
+RUN_DIR=/var/vcap/sys/run/gorouter
+LOG_DIR=/var/vcap/sys/log/gorouter
+PIDFILE=$RUN_DIR/gorouter.pid
+
+source /var/vcap/packages/common/utils.sh
+
+case $1 in
+
+ start)
+ pid_guard $PIDFILE "gorouter"
+
+ # Install libcap2-bin. This can be removed once libcap2-bin is available in the stemcell itself.
+ dpkg -i /var/vcap/packages/gorouter/misc/libcap2-bin_1%3a2.17-2ubuntu1_amd64.deb
+
+ mkdir -p $RUN_DIR
+ mkdir -p $LOG_DIR
+
+ chown -R vcap:vcap $RUN_DIR
+ chown -R vcap:vcap $LOG_DIR
+
+ echo $$ > $PIDFILE
+ chown vcap:vcap $PIDFILE
+
+ # Ephemeral port range
+ echo "1024 65535" > /proc/sys/net/ipv4/ip_local_port_range
+
+ # TCP_FIN_TIMEOUT
+ # This setting determines the time that must elapse before TCP/IP can release a closed connection and reuse
+ # its resources. During this TIME_WAIT state, reopening the connection to the client costs less than establishing
+ # a new connection. By reducing the value of this entry, TCP/IP can release closed connections faster, making more
+ # resources available for new connections. Addjust this in the presense of many connections sitting in the
+ # TIME_WAIT state:
+
+ echo 5 > /proc/sys/net/ipv4/tcp_fin_timeout
+
+ # TCP_TW_RECYCLE
+ # It enables fast recycling of TIME_WAIT sockets. The default value is 0 (disabled). The sysctl documentation
+ # incorrectly states the default as enabled. It can be changed to 1 (enabled) in many cases. Known to cause some
+ # issues with hoststated (load balancing and fail over) if enabled, should be used with caution.
+
+ echo 1 > /proc/sys/net/ipv4/tcp_tw_recycle
+
+ # TCP_TW_REUSE
+ # This allows reusing sockets in TIME_WAIT state for new connections when it is safe from protocol viewpoint.
+ # Default value is 0 (disabled). It is generally a safer alternative to tcp_tw_recycle
+
+ echo 1 > /proc/sys/net/ipv4/tcp_tw_reuse
+
+ # Allow a few more queued connections than are allowed by default
+ echo 1024 > /proc/sys/net/core/somaxconn
+
+ # Allowed number of open file descriptors
+ ulimit -n 100000
+
+ <% if properties.syslog_aggregator %>
+ /var/vcap/packages/syslog_aggregator/setup_syslog_forwarder.sh /var/vcap/jobs/gorouter/config
+ <% end %>
+
+ setcap cap_net_bind_service=+ep /var/vcap/packages/gorouter/bin/router
+
+ exec chpst -u vcap:vcap /var/vcap/packages/gorouter/bin/router \
+ -c /var/vcap/jobs/gorouter/config/gorouter.yml \
+ 1>>$LOG_DIR/gorouter.stdout.log \
+ 2>>$LOG_DIR/gorouter.stderr.log
+
+ ;;
+
+ stop)
+ kill_and_wait $PIDFILE
+
+ ;;
+
+ *)
+ echo "Usage: router_ctl {start|stop}"
+
+ ;;
+
+esac
View
29 jobs/gorouter/templates/gorouter.yml.erb
@@ -0,0 +1,29 @@
+---
+<% if properties.router.status %>
+status:
+ port: <%= properties.router.status.port %>
+ user: <%= properties.router.status.user %>
+ pass: <%= properties.router.status.password %>
+<% end %>
+
+nats:
+ host: <%= properties.nats.address %>:<%= properties.nats.port %>
+ user: <%= properties.nats.user %>
+ pass: <%= properties.nats.password %>
+
+logging:
+ file: /var/vcap/sys/log/gorouter/gorouter.log
+ <% if properties.syslog_aggregator %>
+ syslog: vcap.gorouter
+ <% end %>
+ level: info
+
+port: 80
+index: <%= properties.router.offset ? properties.router.offset + spec.index : spec.index %>
+
+go_max_procs: 8
+
+publish_start_message_interval: 30
+prune_stale_droplets_interval: 30
+droplet_stale_threshold: 120
+publish_active_apps_interval: 0 # 0 means disabled
View
25 jobs/gorouter/templates/syslog_forwarder.conf.erb
@@ -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
13 packages/gorouter/packaging
@@ -0,0 +1,13 @@
+set -e
+
+cp -a gorouter/* $BOSH_INSTALL_TARGET
+cp -a misc $BOSH_INSTALL_TARGET
+
+(
+ cd $BOSH_INSTALL_TARGET
+
+ export GOROOT=$(readlink -nf /var/vcap/packages/golang)
+ export PATH=$GOROOT/bin:$PATH
+
+ bin/go install router/router
+)
View
7 packages/gorouter/spec
@@ -0,0 +1,7 @@
+---
+name: gorouter
+dependencies:
+- golang
+files:
+- gorouter/**/*
+- misc/libcap2-bin_1%3a2.17-2ubuntu1_amd64.deb
1  src/gorouter
@@ -0,0 +1 @@
+Subproject commit a87b4fb9fe8e3e26b2d8a5dfea61537b96b5ffed
Please sign in to comment.
Something went wrong with that request. Please try again.