Created
June 29, 2015 15:47
-
-
Save cgswong/88da13f157e046c80508 to your computer and use it in GitHub Desktop.
Marathon startup
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/bash | |
# Set locale: this is required by the standard Mesos startup scripts | |
echo "info: Setting locale to en_US.UTF-8..." | |
locale-gen en_US.UTF-8 > /dev/null 2>&1 | |
# Start syslog if not started.... | |
echo "info: Starting syslog..." | |
service rsyslog start > /dev/null 2>&1 | |
function start_zookeeper { | |
IFS=, | |
i=1 | |
for server in ${SERVER_LIST}; do | |
echo server.$i=$server:2888:3888 >> /etc/zookeeper/conf/zoo.cfg | |
(( i += 1 )) | |
done | |
echo ${ZK_ID} > /etc/zookeeper/conf/myid | |
echo "info: Starting Zookeeper..." | |
service zookeeper start | |
until /usr/share/zookeeper/bin/zkCli.sh ls / > /dev/null 2>&1 | |
do | |
echo "Waiting for the Zookeeper cluster to be ready" | |
sleep 5 | |
done | |
} | |
function start_slave { | |
echo "info: Mesos slave will try to register with a master using ZooKeeper" | |
echo "info: Starting slave..." | |
echo /var/lib/mesos > /etc/mesos-slave/work_dir | |
echo 'docker,mesos' > /etc/mesos-slave/containerizers | |
echo '5mins' > /etc/mesos-slave/executor_registration_timeout | |
/usr/bin/mesos-init-wrapper slave > /dev/null 2>&1 & | |
# wait for the slave to start | |
sleep 1 && while [[ -z $(netstat -lnt | awk "\$6 == \"LISTEN\" && \$4 ~ \".5051\" && \$1 ~ tcp") ]] ; do | |
echo "info: Waiting for Mesos slave to come online..." | |
sleep 3; | |
done | |
echo "info: Mesos slave started on port 5051" | |
} | |
function start_master { | |
echo in_memory > /etc/mesos/registry | |
echo zk://localhost:2181/mesos > /etc/mesos/zk | |
echo "info: Starting Mesos master..." | |
/usr/bin/mesos-init-wrapper master > /dev/null 2>&1 & | |
# wait for the master to start | |
sleep 1 && while [[ -z $(netstat -lnt | awk "\$6 == \"LISTEN\" && \$4 ~ \".5050\" && \$1 ~ tcp") ]] ; do | |
echo "info: Waiting for Mesos master to come online..." | |
sleep 3; | |
done | |
echo "info: Mesos master started on port 5050" | |
} | |
function start_marathon { | |
rm -f /etc/mesos/zk | |
export MARATHON_MASTER=zk://localhost:2181/mesos | |
export MARATHON_ZK=zk://localhost:2181/marathon | |
if [ ! -d /etc/marathon/conf ]; then | |
mkdir -p /etc/marathon/conf | |
fi | |
echo "http_callback" > /etc/marathon/conf/event_subscriber | |
echo "info: Starting Marathon..." | |
marathon > /dev/null 2>&1 & | |
# wait for marathon to start | |
sleep 1 && while [[ -z $(netstat -lnt | awk "\$6 == \"LISTEN\" && \$4 ~ \".8080\" && \$1 ~ tcp") ]] ; do | |
echo "info: Waiting for Mesos master to come online..." | |
sleep 3; | |
done | |
echo "info: Marathon started on port 8080" | |
} | |
start_zookeeper | |
start_master | |
start_slave | |
start_marathon | |
wait |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment