Created
January 31, 2014 16:34
-
-
Save antonlindstrom/8735710 to your computer and use it in GitHub Desktop.
Marathon upstart script & wrapper
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
#HOST=127.0.0.1 | |
MASTER=`cat /etc/mesos/zk` |
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 -o errexit -o nounset -o pipefail | |
function marathon { | |
local etc_marathon=/etc/marathon | |
local args=() | |
[[ ! -f /etc/default/marathon ]] || . /etc/default/marathon | |
[[ ! ${MASTER:-} ]] || args+=( --master "$MASTER" ) | |
[[ ! ${HOST:-} ]] || args+=( -h "$HOST" ) | |
for f in "$etc_marathon"/* # cluster log_dir port &al. | |
do | |
if [[ -f $f ]] | |
then | |
local name="$(basename "$f")" | |
if [[ $name == '?'* ]] # Recognize flags (options without values) | |
then args+=( --"$name" ) | |
else args+=( --"$name"="$(cat "$f")" ) | |
fi | |
fi | |
done | |
logged /usr/local/marathon/bin/start "${args[@]}" | |
} | |
# Send all output to syslog and tag with PID and executable basename. | |
function logged { | |
local tag="${1##*/}[$$]" | |
exec 1> >(exec logger -p user.info -t "$tag") | |
exec 2> >(exec logger -p user.err -t "$tag") | |
exec "$@" | |
} | |
function msg { out "$*" >&2 ;} | |
function err { local x=$? ; msg "$*" ; return $(( $x == 0 ? 1 : $x )) ;} | |
function out { printf '%s\n' "$*" ;} | |
marathon "$@" |
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 scheduler for Mesos" | |
start on runlevel [2345] | |
stop on runlevel [!2345] | |
respawn | |
respawn limit 10 5 | |
exec /usr/bin/marathon-init-wrapper |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment