-
-
Save tvalladon/e316bee4b58ca082d2190be023565949 to your computer and use it in GitHub Desktop.
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 | |
PATH=./node_modules/.bin:$PATH | |
function debug() { | |
echo "Stopped in REPL. Press ^D to resume, or ^C to abort." | |
local line | |
while read -r -p "> " line; do | |
eval "$line" | |
done | |
echo | |
} | |
function up { ## Build the Infrastructure | |
echo "Launching Infrastructure" | |
docker-compose up -d | |
} | |
function down { ## Destory the Infrastructure | |
echo "Destroying Infrastructure" | |
docker-compose down | |
} | |
function rebuild { ## Destroy and rebuild Infrastructure | |
echo "Rebuilding Infrastructure" | |
down | |
up | |
} | |
function shell { ## Launch a shell in specified <service> | |
if [ $# -ne 1 ]; then echo 1>&2 "Usage: $0 $FUNCNAME <service>";exit 3;fi | |
echo "Launching shell in service $1" | |
docker-compose exec $1 sh | |
} | |
function start { ## Start the Infrastructure or specific [service] | |
echo "Starting Infrastructure" | |
docker-compose start $1 | |
} | |
function stop { ## Stop the Infrastructure or specific [service] | |
echo "Stopping Infrastructure" | |
docker-compose stop $1 | |
} | |
function restart { ## Restart the Infrastructure or specific [service] | |
echo "Starting Infrastructure" | |
docker-compose restart $1 | |
} | |
function list { ## List the Infrastructure | |
echo "Listing Infrastructure" | |
docker-compose ps | |
} | |
function cache { ## Cache control <list | clear> in specific <service> | |
if [ $# -ne 2 ]; then echo 1>&2 "Usage: $0 $FUNCNAME <list | clear> <service>";exit 3;fi | |
if [ $1 = "list" ]; then | |
docker-compose exec $2 sh -c 'ls -alth /tmp/cache' | |
fi | |
if [ $1 = "clear" ]; then | |
docker-compose exec $2 sh -c 'rm -rf /tmp/cache' | |
# Need to restart container so process re-reads cache | |
stop $2 | |
start $2 | |
fi | |
} | |
function list_env { ## List env args in specific <service> | |
if [ $# -ne 1 ]; then echo 1>&2 "Usage: $0 $FUNCNAME <service>";exit 3;fi | |
docker-compose exec $1 sh -c 'set' | |
} | |
function logs { ## Display the logs for Infrastructure or specific [service] | |
docker-compose logs $1 | |
} | |
function help { ## Display usage for this application | |
echo "$0 <task> <args>" | |
grep -E '^function [a-zA-Z_-]+ {.*?## .*$$' $0 | sed -e 's/function //' | sort | awk 'BEGIN {FS = "{.*?## "}; {printf "\033[93m%-30s\033[92m %s\033[0m\n", $1, $2}' | |
} | |
function default { | |
help | |
} | |
TIMEFORMAT="Task completed in %3lR" | |
time "${@:-default}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment