Created
March 7, 2014 20:24
-
-
Save spikeekips/9419280 to your computer and use it in GitHub Desktop.
simple `serf` agent launch script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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