This repository has been archived by the owner on Feb 1, 2020. It is now read-only.
forked from gliderlabs/docker-consul
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding health check stuff for docker world
- Loading branch information
Showing
4 changed files
with
67 additions
and
2 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
main() { | ||
local container_id="$1"; shift | ||
local port="$1"; shift | ||
local cmd="$@" | ||
|
||
local image="$(docker inspect -f "{{.Config.Image}}" $container_id)" | ||
local ip="$(docker inspect -f "{{.NetworkSettings.IPAddress}}" $container_id)" | ||
docker run --rm --net container:$container_id -e "SERVICE_ADDR=$ip:$port" $image "$cmd" | ||
} | ||
|
||
main $@ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
|
||
readonly IMAGE="progrium/consul" | ||
|
||
main() { | ||
local container_id="$1"; shift | ||
local port="$1"; shift | ||
local path="$1"; shift | ||
local opts="$@" | ||
|
||
local ip="$(docker inspect -f "{{.NetworkSettings.IPAddress}}" $container_id)" | ||
local curl_cmd="curl \ | ||
--silent \ | ||
--show-error \ | ||
--fail \ | ||
--dump-header /dev/stderr \ | ||
--retry 2 \ | ||
$opts \ | ||
http://$ip:$port$path > /dev/null" | ||
docker run --rm --net container:$container_id --entrypoint "/bin/bash" $IMAGE -c "$curl_cmd" | ||
} | ||
|
||
main $@ |