-
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.
* Add `MakeFile`s that make it easy to spin up the needed infra, startup the Cipher server, and Go workers * Update README.md for the Cipher demo Signed-off-by: lloydmeta <[email protected]>
- Loading branch information
Showing
4 changed files
with
100 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
GO_WORKER_COUNT ?= 5 | ||
|
||
install-eck: | ||
@$(MAKE) install-eck -C k8s | ||
|
||
k8s-deploy: | ||
@$(MAKE) deploy -C k8s | ||
|
||
k8s-teardown: | ||
@$(MAKE) teardown -C k8s | ||
|
||
k8s-show-credentials: | ||
@$(MAKE) show-credentials -C k8s | ||
|
||
start-go-workers: | ||
@worker-go/start-workers ${GO_WORKER_COUNT} | ||
|
||
start-cipher-server: | ||
@server/start-server |
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,15 @@ | ||
#!/usr/bin/env bash | ||
|
||
cd "$(dirname "$0")" | ||
|
||
while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:8080/recurring_tasques)" != "200" ]]; do | ||
echo "Waiting for Tasques server to come online ..." | ||
sleep 5; | ||
done | ||
|
||
while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:9201)" != "200" ]]; do | ||
echo "Waiting for Cipher ES server to come online ..." | ||
sleep 5; | ||
done | ||
|
||
go run main.go |
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,47 @@ | ||
#!/usr/bin/env bash | ||
cd "$(dirname "$0")" | ||
worker_process_ids=() | ||
|
||
function kill_workers() { | ||
echo "Sending SIGINT to workers workers" | ||
for pid in "${worker_process_ids[@]}"; do | ||
kill -2 $pid | ||
done | ||
exit 0 | ||
} | ||
|
||
number_of_workers=$1 | ||
|
||
number_re='^[0-9]+$' | ||
if ! [[ $number_of_workers =~ $number_re ]]; then | ||
echo "Error: Worker number argument (first and only) not a number" >&2; exit 1 | ||
fi | ||
|
||
trap kill_workers SIGINT SIGTERM SIGHUP | ||
|
||
while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:8080/recurring_tasques)" != "200" ]]; do | ||
echo "Waiting for Tasques server to come online ..." | ||
sleep 5; | ||
done | ||
|
||
while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:9201)" != "200" ]]; do | ||
echo "Waiting for Cipher ES server to come online ..." | ||
sleep 5; | ||
done | ||
|
||
for ((i=0; i<number_of_workers; i++)); do | ||
worker_id="go-worker-${i}" | ||
echo "Starting ${worker_id} .." | ||
if [ $((i%2)) -eq 0 ]; then | ||
go run main.go --worker-id ${worker_id} & | ||
else | ||
go run main.go --worker-id ${worker_id} -f true & | ||
fi | ||
worker_process_ids+=($!) | ||
done | ||
|
||
echo "Workers started, hit CTRL+C to stop" | ||
|
||
while true; do | ||
sleep 1; | ||
done |