Skip to content
This repository has been archived by the owner on Jan 21, 2022. It is now read-only.

Commit

Permalink
Adding the ACM to bosh.
Browse files Browse the repository at this point in the history
New acm submodule pointer to the release repo.
Jobs and packages.
Discovery on nats.
Logging to syslog.
Uses a postgres db.

Change-Id: Ibe6bd0917aad564103ad95ee9ac6408698d76f2b
  • Loading branch information
joeldsa committed Apr 13, 2012
1 parent 5657c24 commit 8618d94
Show file tree
Hide file tree
Showing 9 changed files with 132 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Expand Up @@ -13,3 +13,6 @@
[submodule "src/vblob_src"]
path = src/vblob_src
url = git@github.com:cloudfoundry/vblob.git
[submodule "src/acm"]
path = src/acm
url = git@github.com:cloudfoundry/acm.git
5 changes: 5 additions & 0 deletions jobs/acm/monit
@@ -0,0 +1,5 @@
check process acm
with pidfile /var/vcap/sys/run/acm/acm.pid
start program "/var/vcap/jobs/acm/bin/acm_ctl start"
stop program "/var/vcap/jobs/acm/bin/acm_ctl stop"
group vcap
12 changes: 12 additions & 0 deletions jobs/acm/spec
@@ -0,0 +1,12 @@
---
name: acm
templates:
acm_ctl.erb: bin/acm_ctl
acm.yml.erb: config/acm.yml
syslog_forwarder.conf.erb: config/syslog_forwarder.conf
packages:
- libpq
- common
- ruby
- syslog_aggregator
- acm
16 changes: 16 additions & 0 deletions jobs/acm/templates/acm.yml.erb
@@ -0,0 +1,16 @@
---
pid: /var/vcap/sys/run/acm/acm.pid
name: ACM
port: 9090
mbus: nats://<%= properties.nats.user %>:<%= properties.nats.password %>@<%= properties.nats.address %>:<%= properties.nats.port %>/
logging:
level: info
file: /var/vcap/sys/log/acm/acm.log
syslog: vcap.acm
db:
database: postgres://<%= properties.acm.db.user %>:<%= properties.acm.db.password %>@<%= properties.acm.db.address %>:<%= properties.acm.db.port %>/<%= properties.acm.db.dbname %>
max_connections: 25
pool_timeout: 2000
basic_auth:
user: <%= properties.acm.user %>
password: <%= properties.acm.password %>
44 changes: 44 additions & 0 deletions jobs/acm/templates/acm_ctl.erb
@@ -0,0 +1,44 @@
#!/bin/bash -e

RUN_DIR=/var/vcap/sys/run/acm
LOG_DIR=/var/vcap/sys/log/acm
CONFIG_DIR=/var/vcap/jobs/acm/config
PIDFILE=$RUN_DIR/acm.pid
PACKAGE_DIR=/var/vcap/packages/acm
export PATH=/var/vcap/packages/ruby/bin:$PATH

source /var/vcap/packages/common/utils.sh

case $1 in

start)
pid_guard $PIDFILE "ACM"

mkdir -p $RUN_DIR/acm
mkdir -p $LOG_DIR
echo $$ > $PIDFILE

chown -R vcap:vcap $RUN_DIR
chown -R vcap:vcap $LOG_DIR

<% if properties.syslog_aggregator %>
/var/vcap/packages/syslog_aggregator/setup_syslog_forwarder.sh $CONFIG_DIR
<% end %>

exec chpst -u vcap:vcap $PACKAGE_DIR/acm/bin/acm -c $CONFIG_DIR/acm.yml \
>>$LOG_DIR/acm.stdout.log \
2>>$LOG_DIR/acm.stderr.log

;;

stop)
kill_and_wait $PIDFILE

;;

*)
echo "Usage: acm_ctl {start|stop}"

;;

esac
29 changes: 29 additions & 0 deletions jobs/acm/templates/syslog_forwarder.conf.erb
@@ -0,0 +1,29 @@
<% if properties.syslog_aggregator %>
$ModLoad imuxsock # local message reception (rsyslog uses a datagram socket)
$MaxMessageSize 4k # default is 2k

$ModLoad imudp # the java log4j appender only works with udp
$UDPServerRun 514

$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 %>
14 changes: 14 additions & 0 deletions packages/acm/packaging
@@ -0,0 +1,14 @@
# abort script on any command that exit with a non zero value
set -e

cp -a * ${BOSH_INSTALL_TARGET}

(
cd ${BOSH_INSTALL_TARGET}/acm

bundle_cmd=/var/vcap/packages/ruby/bin/bundle
libpq_dir=/var/vcap/packages/libpq

$bundle_cmd config build.pg --with-pg-lib=$libpq_dir/lib --with-pg-include=$libpq_dir/include
$bundle_cmd install --local --deployment --without development test
)
8 changes: 8 additions & 0 deletions packages/acm/spec
@@ -0,0 +1,8 @@
---
name: acm
dependencies:
- libpq
- ruby
files:
- acm/**/*
- core/common/**/*
1 change: 1 addition & 0 deletions src/acm
Submodule acm added at b4ee41

0 comments on commit 8618d94

Please sign in to comment.