Skip to content

Instantly share code, notes, and snippets.

@spikeekips
Created March 7, 2014 20:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spikeekips/9419280 to your computer and use it in GitHub Desktop.
Save spikeekips/9419280 to your computer and use it in GitHub Desktop.
simple `serf` agent launch script
#!/bin/sh
n=$1
args=$(echo $@ | sed -e "s/^$1//g")
if [ "$(uname)" == "Darwin" ];then
ips=$(ifconfig | grep '\<inet\>' | awk '{print $2}')
for i in $ips
do
echo $i | grep '^127\.' &>/dev/null
if [ $? -eq 0 ];then
continue
fi
ip=$i
break
done
else
ip=$(ip addr show eth0 | grep '\<inet\>' | awk '{print $2}' | sed -s 's/\/.*//g')
fi
node="machine${n}"
port_node=$(expr 7900 + $n)
port_rpc=$(expr 7300 + $n)
args_join=""
if [ $n -ne 0 ];then
args_join="-join=$ip:$(expr $port_node - 1)"
fi
serf \
agent \
-log-level=debug \
-node=$node \
-bind=${ip}:${port_node} \
-rpc-addr=${ip}:${port_rpc} \
$args_join \
$args
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment