Last active
August 29, 2015 13:58
-
-
Save jalaziz/10089274 to your computer and use it in GitHub Desktop.
Marathon Upstart
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
description "marathon" | |
# Start just after the System-V jobs (rc) to ensure networking and zookeeper | |
# are started. This is as simple as possible to ensure compatibility with | |
# Ubuntu, Debian, CentOS, and RHEL distros. See: | |
# http://upstart.ubuntu.com/cookbook/#standard-idioms | |
start on stopped rc RUNLEVEL=[2345] | |
respawn | |
script | |
MARATHON_HOME=/opt/marathon | |
HEAP=512m | |
if [ -z ${MESOS_NATIVE_LIBRARY+x} ] | |
then | |
search_paths='/usr/lib /usr/local/lib' | |
echo "MESOS_NATIVE_LIBRARY is not set. Searching in $search_paths." | |
export MESOS_NATIVE_LIBRARY=$(find -L $search_paths -name libmesos.dylib -or -name libmesos.so 2>/dev/null | head -n1) | |
fi | |
#If we're on Amazon, let's use the public hostname so redirect works as expected. | |
if public_hostname="$( curl -sSf --connect-timeout 1 http://169.254.169.254/latest/meta-data/public-hostname )" | |
then | |
HOSTNAME=$public_hostname | |
else | |
HOSTNAME=`hostname` | |
fi | |
#If /etc/mesos/zk exists, use it to configure zookeeper | |
if [ -f /etc/mesos/zk ] | |
then | |
MASTER=`cat /etc/mesos/zk` | |
ZK_HOSTS=`echo $MASTER | sed 's/zk:\/\///g;s/\/.*//'` | |
fi | |
# Override defaults with user-specificed defaults | |
[ ! -f /etc/default/marathon ] || . /etc/default/marathon | |
MARATHON_JAR=${MARATHON_JAR:-`echo $MARATHON_HOME/target/marathon*-jar-with-dependencies.jar`} | |
VM_OPTS=${VM_OPTS:--Xmx"$HEAP" -Xms"$HEAP"} | |
# Redirect stdout to syslog | |
mkfifo /tmp/marathon-log-stdout-fifo | |
( logger -p user.info -t marathon </tmp/marathon-log-stdout-fifo & ) | |
exec 1>/tmp/marathon-log-stdout-fifo | |
rm /tmp/marathon-log-stdout-fifo | |
# Redirect stderr to syslog | |
mkfifo /tmp/marathon-log-stderr-fifo | |
( logger -p user.err -t marathon </tmp/marathon-log-stderr-fifo & ) | |
exec 2>/tmp/marathon-log-stderr-fifo | |
rm /tmp/marathon-log-stderr-fifo | |
exec java \ | |
${VM_OPTS:+$VM_OPTS} \ | |
${LIB_PATH:+-Djava.library.path=$LIB_PATH} \ | |
${MARATHON_JAR:+-cp $MARATHON_JAR mesosphere.marathon.Main} \ | |
${ZK_HOSTS:+--zk_hosts "$ZK_HOSTS"} \ | |
${MASTER:+--master $MASTER} \ | |
${HOSTNAME:+--hostname $HOSTNAME} \ | |
${HTTP_PORT:+--http_port $HTTP_PORT} \ | |
${OPTS:+$OPTS} | |
end script |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment