Navigation Menu

Skip to content

Commit

Permalink
Patch riak script to use SmartOS conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredmorrow committed Jul 20, 2012
1 parent eced982 commit fdcbe7a
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
4 changes: 4 additions & 0 deletions package/smartos/Makefile
Expand Up @@ -138,12 +138,16 @@ $(BUILD_STAGE_DIR): buildrel


# Build the release we need to package
# * Patch rel/files/riak with our version
# * Ensure all binaries are executable
# * copy the vars.config over for build config
buildrel: $(BUILD_RIAK_PATH)
cp $(BUILD_RIAK_PATH)/rel/files/riak $(BUILD_RIAK_PATH)/rel/files/riak.tmp
sed -e "s/^RIAK_VERSION.*$$/RIAK_VERSION=\"${VERSIONSTRING}\"/" < \
$(BUILD_RIAK_PATH)/rel/files/riak.tmp > $(BUILD_RIAK_PATH)/rel/files/riak
cp $(PKGERDIR)/patches/rel_riak.patch $(BUILD_RIAK_PATH)/rel/files/
cd $(BUILD_RIAK_PATH)/rel/files && \
patch -p3 < rel_riak.patch
cp -f $(PKGERDIR)/vars.config $(BUILD_RIAK_PATH)/rel/vars.config
$(MAKE) -C $(BUILD_RIAK_PATH) deps rel
chmod 0755 $(BUILD_RIAK_PATH)/rel/riak/bin/* $(BUILD_RIAK_PATH)/rel/riak/erts-*/bin/*
Expand Down
63 changes: 63 additions & 0 deletions package/smartos/patches/rel_riak.patch
@@ -0,0 +1,63 @@
diff --git a/rel/files/riak b/rel/files/riak
index 707bc12..fdfe710 100755
--- a/rel/files/riak
+++ b/rel/files/riak
@@ -105,6 +105,21 @@ sed -n '/Begin SSL distribution items/,/End SSL distribution items/p' \
# Check the first argument for instructions
case "$1" in
start)
+
+ if [ "${SMF_METHOD}" != "start" ]; then
+ echo "***"
+ echo "Warning: please use 'svcadm enable riak' instead"
+ echo "***"
+ fi
+
+ # Make sure we have access to enough file descriptors
+ ULIMIT_S=$(prctl -n process.max-file-descriptor -t basic -P $$ | awk '/max-file-descriptor/ { print $3 }')
+ ULIMIT_H=$(prctl -n process.max-file-descriptor -t priv -P $$ | awk '/max-file-descriptor/ { print $3 }')
+ if [ ${ULIMIT_S} -lt ${ULIMIT_H} ]; then
+ echo "Trying to raise the file descriptor limit to maximum allowed."
+ prctl -n process.max-file-descriptor -t basic -v ${ULIMIT_H} $$ || true
+ fi
+
# Make sure there is not already a node running
RES=`ping_node`
if [ "$RES" = "pong" ]; then
@@ -151,6 +166,12 @@ case "$1" in
;;

stop)
+ if [ "${SMF_METHOD}" != "stop" ]; then
+ echo "***"
+ echo "Warning: please use 'svcadm disable riak' instead"
+ echo "***"
+ fi
+
UNAME_S=`uname -s`
case $UNAME_S in
Darwin)
@@ -212,7 +233,7 @@ case "$1" in
attach)
if [ "$2" = "-f" ]; then
echo "Forcing connection..."
- else
+ else
# Make sure a node is running
RES=`ping_node`
ES=$?
@@ -227,6 +248,14 @@ case "$1" in
;;

console)
+ # Make sure we have access to enough file descriptors
+ ULIMIT_S=$(prctl -n process.max-file-descriptor -t basic -P $$ | awk '/max-file-descriptor/ { print $3 }')
+ ULIMIT_H=$(prctl -n process.max-file-descriptor -t priv -P $$ | awk '/max-file-descriptor/ { print $3 }')
+ if [ ${ULIMIT_S} -lt ${ULIMIT_H} ]; then
+ echo "Trying to raise the file descriptor limit to maximum allowed."
+ prctl -n process.max-file-descriptor -t basic -v ${ULIMIT_H} $$ || true
+ fi
+
RES=`ping_node`
if [ "$RES" = "pong" ]; then
echo "Node is already running - use '$SCRIPT attach' instead"

0 comments on commit fdcbe7a

Please sign in to comment.