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

Commit

Permalink
Add pre-commit hook.
Browse files Browse the repository at this point in the history
  • Loading branch information
brndnmtthws committed Apr 5, 2016
1 parent 6d3a073 commit 17ec444
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 53 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.git
tests
hooks
scripts
.*
Dockerfile
96 changes: 43 additions & 53 deletions Longhelp.md
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,49 @@ frontend marathon_https_in
bind *:443 ssl {sslCerts}
mode http
```
## `HAPROXY_HTTP_BACKEND_PROXYPASS`
*Overridable*

Specified as `HAPROXY_HTTP_BACKEND_PROXYPASS` template or with label `HAPROXY_{n}_HTTP_BACKEND_PROXYPASS`.

Set the location to use for mapping local server URLs to remote servers + URL.
Ex: HAPROXY_0_HTTP_BACKEND_PROXYPASS = '/path/to/redirect


**Default template for `HAPROXY_HTTP_BACKEND_PROXYPASS`:**
```
http-request set-header Host {hostname}
reqirep "^([^ :]*)\ {proxypath}(.*)" "\1\ /\2"
```
## `HAPROXY_HTTP_BACKEND_REDIR`
*Overridable*

Specified as `HAPROXY_HTTP_BACKEND_REDIR` template or with label `HAPROXY_{n}_HTTP_BACKEND_REDIR`.

Set the path to redirect the root of the domain to
Ex: HAPROXY_0_HTTP_BACKEND_REDIR = '/my/content'


**Default template for `HAPROXY_HTTP_BACKEND_REDIR`:**
```
acl is_root path -i /
acl is_domain hdr(host) -i {hostname}
redirect code 301 location {redirpath} if is_domain is_root
```
## `HAPROXY_HTTP_BACKEND_REVPROXY`
*Overridable*

Specified as `HAPROXY_HTTP_BACKEND_REVPROXY` template or with label `HAPROXY_{n}_HTTP_BACKEND_REVPROXY`.

Set the URL in HTTP response headers sent from a reverse proxied server. It only updates Location, Content-Location and URL.
Ex: HAPROXY_0_HTTP_BACKEND_REVPROXY = '/my/content'


**Default template for `HAPROXY_HTTP_BACKEND_REVPROXY`:**
```
acl hdr_location res.hdr(Location) -m found
rspirep "^Location: (https?://{hostname}(:[0-9]+)?)?(/.*)" "Location: {rootpath} if hdr_location"
```
## `HAPROXY_HTTP_FRONTEND_ACL`
*Overridable*

Expand Down Expand Up @@ -575,59 +618,6 @@ glues the acl names to the appropriate backend
```
use_backend {backend} if host_{cleanedUpHostname} path_{backend}
```

**Default template for `HAPROXY_HTTP_BACKEND_PROXYPASS`:**
```
http-request set-header Host {hostname}
reqirep "^([^ :]*)\ {proxypath}(.*)" "\\1\ /\\2"
```
## `HAPROXY_HTTP_FRONTEND_HEAD`
*Global*

Specified as `HAPROXY_HTTP_BACKEND_PROXYPASS` template.

HTTP backend options for mapping local server URLs to remote servers + URL.
Defined per app using the `HAPROXY_{0}_HTTP_BACKEND_PROXYPASS` label.

Ex: `HAPROXY_0_HTTP_BACKEND_PROXYPASS = '/path/to/resource'`


**Default template for `HAPROXY_HTTP_BACKEND_REVPROXY`:**
```
acl hdr_location res.hdr(Location) -m found
rspirep "^Location: (https?://{hostname}(:[0-9]+)?)?(/.*)" "Location: \
{rootpath} if hdr_location"
```
## `HAPROXY_HTTP_BACKEND_REVPROXY`
*Global*

Specified as `HAPROXY_HTTP_BACKEND_REVPROXY` template.

HTTP option to set response headers sent from a reverse proxied server. \
It only updates Location, Content-Location and URL.
Defined per app using the `HAPROXY_{0}_HTTP_BACKEND_REVPROXY` label.

Ex: `HAPROXY_0_HTTP_BACKEND_REVPROXY = '/path/to/resource/'`

**Default template for `HTTP_BACKEND_REDIR`:**
```
acl is_root path -i /
acl is_domain hdr(host) -i {hostname}
redirect code 301 location {redirpath} if is_domain is_root
```
## `HAPROXY_HTTP_BACKEND_REDIR`
*Global*

Specified as `HAPROXY_HTTP_BACKEND_REDIR` template.

HTTP backend options to set the path to redirect the root of the domain to
Defined per app using the `HAPROXY_{0}_HTTP_BACKEND_REDIR` label.

Ex: `HAPROXY_0_HTTP_BACKEND_REDIR = '/path/to/resource/'`

## Other Labels
These labels may be used to configure other app settings.

Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,15 @@ An example minimal configuration for a [test instance of nginx is included here]
```

Zero downtime deployments are accomplished through the use of a Lua module, which reports the number of HAProxy processes which are currently running by hitting the stats endpoint at the `/_haproxy_getpids`. After a restart, there will be multiple HAProxy PIDs until all remaining connections have gracefully terminated. By waiting for all connections to complete, you may safely and deterministically drain tasks. A caveat of this, however, is that if you have any long-lived connections on the same LB, HAProxy will continue to run and serve those connections until they complete, thereby breaking this technique.

## Contributing

PRs are welcome, but here are a few general guidelines:

- Avoid making changes which may break existing behaviour
- Document new features
- Update/include tests for new functionality
- Use the pre-commit hook to automatically generate docs:
```
bash /path/to/marathon-lb/scripts/install-git-hooks.sh
```
13 changes: 13 additions & 0 deletions hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
set -o errexit -o nounset -o pipefail

echo "RUNNING PRE-COMMIT";

GIT_HOOKS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )";
REPO_DIR=$GIT_HOOKS_DIR/../..
SCRIPTS_DIR=$REPO_DIR/scripts

$SCRIPTS_DIR/build-docs.sh

# Fail if there are unstaged changes
git diff --exit-code
10 changes: 10 additions & 0 deletions scripts/build-docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -o errexit -o nounset -o pipefail

SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )";
REPO_DIR="$SCRIPTS_DIR/..";
META_DIR="$REPO_DIR/repo/meta"

echo "Building docs...";
$REPO_DIR/"marathon_lb.py" --longhelp > $REPO_DIR/Longhelp.md;
echo "OK";
17 changes: 17 additions & 0 deletions scripts/install-git-hooks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
set -o errexit -o nounset -o pipefail

SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )";
REPO_DIR=$SCRIPTS_DIR/..
HOOKS_DIR=$REPO_DIR/hooks
GIT_HOOKS_DIR=$REPO_DIR/.git/hooks

echo "Installing git hooks...";

for file in $(ls $HOOKS_DIR); do
echo "Copying $file";
cp "$HOOKS_DIR/$file" $GIT_HOOKS_DIR/;
chmod +x "$GIT_HOOKS_DIR/$file";
done

echo "OK";

0 comments on commit 17ec444

Please sign in to comment.