Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Commit

Permalink
Runsvdir (#283)
Browse files Browse the repository at this point in the history
* upstream merge

* add http basic auth support

* add haproxy acme plugin

* fix some missing/extra labels

* Revert "add haproxy acme plugin"

This reverts commit 15e7a25.

* upstream merge

* add http basic auth support

* add haproxy acme plugin

* fix some missing/extra labels

* Revert "add haproxy acme plugin"

This reverts commit 15e7a25.

* Use runsvdir to launch marathon_lb.py and haproxy.

* change to /marathon-lb dir before running, templates dir is relative to current dir.
  • Loading branch information
vixns authored and brndnmtthws committed Sep 8, 2016
1 parent 75d9b08 commit ced845f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -346,4 +346,4 @@ PRs are welcome, but here are a few general guidelines:
- Use the pre-commit hook to automatically generate docs:
```
bash /path/to/marathon-lb/scripts/install-git-hooks.sh
```
```
48 changes: 30 additions & 18 deletions run
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ set -euo pipefail

SYSLOG_SOCKET=${SYSLOG_SOCKET:-/dev/null}

LB_SERVICE="/marathon-lb/service/lb"
mkdir -p $LB_SERVICE

HAPROXY_SERVICE="/marathon-lb/service/haproxy"
mkdir -p $HAPROXY_SERVICE/env

Expand Down Expand Up @@ -70,12 +73,6 @@ if [ -n "${HAPROXY_SYSCTL_PARAMS-}" ]; then
fi
fi

/usr/bin/runsv "$HAPROXY_SERVICE" &
RUNSV=$!
ARGS=""

trap "kill $RUNSV; wait $RUNSV; exit 0" TERM INT

MODE=$1; shift
case "$MODE" in
poll)
Expand All @@ -99,17 +96,32 @@ case "$MODE" in
;;
esac

while true; do
/marathon-lb/marathon_lb.py \
cat > $LB_SERVICE/run << EOF
#!/bin/sh
exec 2>&1
cd /marathon-lb
exec /marathon-lb/marathon_lb.py \
--syslog-socket $SYSLOG_SOCKET \
--haproxy-config /marathon-lb/haproxy.cfg \
--ssl-certs "$SSL_CERTS" \
--command "sv reload $HAPROXY_SERVICE" \
$ARGS "$@" &
wait $! || exit $? # Needed for the traps to work
if [ "$MODE" != "poll" ]; then
exit 0
fi
sleep "$POLL_INTERVAL" &
wait $!
done
--ssl-certs "${SSL_CERTS}" \
--command "sv reload ${HAPROXY_SERVICE}" \
$ARGS ${@}
EOF
chmod 755 $LB_SERVICE/run


if [ "${MODE}" == "poll" ]; then

cat > $LB_SERVICE/finish << EOF
#!/bin/sh
sleep ${POLL_INTERVAL}
EOF
chmod 755 $LB_SERVICE/finish

fi

runsvdir -P /marathon-lb/service &
trap "kill -s 1 $!" TERM INT
wait

0 comments on commit ced845f

Please sign in to comment.