Last active
June 7, 2020 19:30
-
-
Save lancewf/d81b6c8350bb3366b04040dcaa58752b 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 | |
export MYSQL_PORT=3306 | |
export MMSN_PORT=8080 | |
export PHP_PORT=9000 | |
export REDIS_PORT=6379 | |
export MONEY_CHECKER_SERVER_PORT=8081 | |
export WIKI_PORT=8082 | |
export WHALEDISENTANGLEMENT_HOME_PORT=8083 | |
export HAWAII_ALASKA_WHALEDISENTANGLEMENT_PORT=8084 | |
export MEDIA_WHALEDISENTANGLEMENT_PORT=8085 | |
export WEST_COAST_WHALEDISENTANGLEMENT_PORT=8086 | |
export PACIFIC_NORTHWEST_WHALEDISENTANGLEMENT_PORT=8087 | |
export WEST_COAST_TRAINING_WHALEDISENTANGLEMENT_PORT=8088 | |
export MONEY_DATA_SERVER_PORT=8089 | |
export ACOUSTICS_WHALEDISENTANGLEMENT_PORT=8090 | |
export REQUESTBIN_PORT=8091 | |
export PHPMYADMIN_PORT=8092 | |
export WHALE_SERVER_PORT=80 | |
function start() { | |
start_whale_server | |
} | |
function start_whale_server() { | |
start_mmsn | |
start_money_checker_server | |
start_wiki | |
start_whaledisentanglement_home | |
start_hawaii_alaska_whaledisentanglement | |
start_media_whaledisentanglement | |
start_west_coast_whaledisentanglement | |
start_pacific_northwest_whaledisentanglement | |
start_west_coast_training_whaledisentanglement | |
start_money_data_server | |
start_acoustics_whaledisentanglement | |
start_requestbin | |
#start_phpmyadmin | |
hab svc load lancewf/whale-server --strategy at-once --bind money_data_server:money_data_server.default --bind mmsn:mmsn.default --bind money-checker-server:Money-Checker-Server.default --bind wiki:wiki.default --bind home-whale-dis:whaledisentanglement_home.default --bind hawaii-alaska-whale-dis:hawaii-alaska-whaledisentanglement.default --bind media-whale-dis:media-whaledisentanglement.default --bind west-coast-whale-dis:west-coast-whaledisentanglement.default --bind pacific-northwest-whale-dis:pacific-northwest-whaledisentanglement.default --bind west-coast-training-whale-dis:west_coast_training_whaledisentanglement.default --bind acoustics-whaledisentanglement:acoustics-whaledisentanglement.default --bind requestbin:requestbin.default | |
wait_or_fail_for_port_to_listen $WHALE_SERVER_PORT | |
} | |
function create_config_dir() { | |
mkdir -p /hab/user/whale-server/config | |
mkdir -p /hab/user/mysql/config | |
mkdir -p /hab/user/php/config | |
mkdir -p /hab/user/mmsn/config | |
mkdir -p /hab/user/Money-Checker-Server/config | |
mkdir -p /hab/user/wiki/config | |
mkdir -p /hab/user/whaledisentanglement_home/config | |
mkdir -p /hab/user/hawaii-alaska-whaledisentanglement/config | |
mkdir -p /hab/user/media-whaledisentanglement/config | |
mkdir -p /hab/user/west-coast-whaledisentanglement/config | |
mkdir -p /hab/user/pacific-northwest-whaledisentanglement/config | |
mkdir -p /hab/user/west_coast_training_whaledisentanglement/config | |
mkdir -p /hab/user/money_data_server/config | |
mkdir -p /hab/user/acoustics-whaledisentanglement/config | |
} | |
function start_phpmyadmin() { | |
install_if_missing core/busybox-static netstat; | |
netstat -an | grep $PHPMYADMIN_PORT | grep LISTEN >/dev/null 2>/dev/null | |
if [ $? == 0 ]; then | |
echo "phpMyAdmin is already running"; | |
return; | |
fi | |
start_mysql | |
start_php | |
hab svc load lancewf/phpMyAdmin --strategy at-once --bind database:mysql.default --bind php:php.default | |
wait_or_fail_for_port_to_listen $PHPMYADMIN_PORT | |
} | |
function start_requestbin() { | |
install_if_missing core/busybox-static netstat; | |
netstat -an | grep $REQUESTBIN_PORT | grep LISTEN >/dev/null 2>/dev/null | |
if [ $? == 0 ]; then | |
echo "requestbin is already running"; | |
return; | |
fi | |
start_redis | |
hab svc load lancewf/requestbin --strategy at-once --bind redis:redis.default | |
wait_or_fail_for_port_to_listen $REQUESTBIN_PORT | |
} | |
function start_acoustics_whaledisentanglement() { | |
install_if_missing core/busybox-static netstat; | |
netstat -an | grep $ACOUSTICS_WHALEDISENTANGLEMENT_PORT | grep LISTEN >/dev/null 2>/dev/null | |
if [ $? == 0 ]; then | |
echo "acoustics-whaledisentanglement is already running"; | |
return; | |
fi | |
hab svc load lancewf/acoustics-whaledisentanglement --strategy at-once | |
wait_or_fail_for_port_to_listen $ACOUSTICS_WHALEDISENTANGLEMENT_PORT | |
} | |
function start_money_data_server() { | |
install_if_missing core/busybox-static netstat; | |
netstat -an | grep $MONEY_DATA_SERVER_PORT | grep LISTEN >/dev/null 2>/dev/null | |
if [ $? == 0 ]; then | |
echo "money_data_server is already running"; | |
return; | |
fi | |
start_mysql | |
hab svc load lancewf/money_data_server --strategy at-once --bind database:mysql.default | |
wait_or_fail_for_port_to_listen $MONEY_DATA_SERVER_PORT | |
} | |
function start_west_coast_training_whaledisentanglement() { | |
install_if_missing core/busybox-static netstat; | |
netstat -an | grep $WEST_COAST_TRAINING_WHALEDISENTANGLEMENT_PORT | grep LISTEN >/dev/null 2>/dev/null | |
if [ $? == 0 ]; then | |
echo "west_coast_training_whaledisentanglement is already running"; | |
return; | |
fi | |
hab svc load lancewf/west_coast_training_whaledisentanglement --strategy at-once | |
wait_or_fail_for_port_to_listen $WEST_COAST_TRAINING_WHALEDISENTANGLEMENT_PORT | |
} | |
function start_pacific_northwest_whaledisentanglement() { | |
install_if_missing core/busybox-static netstat; | |
netstat -an | grep $PACIFIC_NORTHWEST_WHALEDISENTANGLEMENT_PORT | grep LISTEN >/dev/null 2>/dev/null | |
if [ $? == 0 ]; then | |
echo "pacific-northwest-whaledisentanglement is already running"; | |
return; | |
fi | |
start_mysql | |
start_php | |
hab svc load lancewf/pacific-northwest-whaledisentanglement --strategy at-once --bind database:mysql.default --bind php:php.default | |
wait_or_fail_for_port_to_listen $PACIFIC_NORTHWEST_WHALEDISENTANGLEMENT_PORT | |
} | |
function start_west_coast_whaledisentanglement() { | |
install_if_missing core/busybox-static netstat; | |
netstat -an | grep $WEST_COAST_WHALEDISENTANGLEMENT_PORT | grep LISTEN >/dev/null 2>/dev/null | |
if [ $? == 0 ]; then | |
echo "west-coast-whaledisentanglement is already running"; | |
return; | |
fi | |
start_mysql | |
start_php | |
hab svc load lancewf/west-coast-whaledisentanglement --strategy at-once --bind database:mysql.default --bind php:php.default | |
wait_or_fail_for_port_to_listen $WEST_COAST_WHALEDISENTANGLEMENT_PORT | |
} | |
function start_media_whaledisentanglement() { | |
install_if_missing core/busybox-static netstat; | |
netstat -an | grep $MEDIA_WHALEDISENTANGLEMENT_PORT | grep LISTEN >/dev/null 2>/dev/null | |
if [ $? == 0 ]; then | |
echo "meida-whaledisentanglement is already running"; | |
return; | |
fi | |
start_mysql | |
start_php | |
hab svc load lancewf/media-whaledisentanglement --strategy at-once --bind database:mysql.default --bind php:php.default | |
wait_or_fail_for_port_to_listen $MEDIA_WHALEDISENTANGLEMENT_PORT | |
} | |
function start_hawaii_alaska_whaledisentanglement() { | |
install_if_missing core/busybox-static netstat; | |
netstat -an | grep $HAWAII_ALASKA_WHALEDISENTANGLEMENT_PORT | grep LISTEN >/dev/null 2>/dev/null | |
if [ $? == 0 ]; then | |
echo "hawaii-alaska-whaledisentanglement is already running"; | |
return; | |
fi | |
start_mysql | |
start_php | |
hab svc load lancewf/hawaii-alaska-whaledisentanglement --strategy at-once --bind database:mysql.default --bind php:php.default | |
wait_or_fail_for_port_to_listen $HAWAII_ALASKA_WHALEDISENTANGLEMENT_PORT | |
} | |
function start_whaledisentanglement_home() { | |
install_if_missing core/busybox-static netstat; | |
netstat -an | grep $WHALEDISENTANGLEMENT_HOME_PORT | grep LISTEN >/dev/null 2>/dev/null | |
if [ $? == 0 ]; then | |
echo "whaledisentanglement_home is already running"; | |
return; | |
fi | |
hab svc load lancewf/whaledisentanglement_home --strategy at-once | |
wait_or_fail_for_port_to_listen $WHALEDISENTANGLEMENT_HOME_PORT | |
} | |
function start_wiki() { | |
install_if_missing core/busybox-static netstat; | |
netstat -an | grep $WIKI_PORT | grep LISTEN >/dev/null 2>/dev/null | |
if [ $? == 0 ]; then | |
echo "wiki is already running"; | |
return; | |
fi | |
start_mysql | |
start_php | |
hab svc load lancewf/wiki --strategy at-once --bind database:mysql.default --bind php:php.default | |
wait_or_fail_for_port_to_listen $WIKI_PORT | |
} | |
function start_money_checker_server() { | |
install_if_missing core/busybox-static netstat; | |
netstat -an | grep $MONEY_CHECKER_SERVER_PORT | grep LISTEN >/dev/null 2>/dev/null | |
if [ $? == 0 ]; then | |
echo "Money-Checker-Server is already running"; | |
return; | |
fi | |
start_mysql | |
start_php | |
hab svc load lancewf/Money-Checker-Server --strategy at-once --bind database:mysql.default --bind php:php.default | |
wait_or_fail_for_port_to_listen $MONEY_CHECKER_SERVER_PORT | |
} | |
function start_mmsn() { | |
install_if_missing core/busybox-static netstat; | |
netstat -an | grep $MMSN_PORT | grep LISTEN >/dev/null 2>/dev/null | |
if [ $? == 0 ]; then | |
echo "mmsn is already running"; | |
return; | |
fi | |
start_mysql | |
start_php | |
hab svc load lancewf/mmsn --strategy at-once --bind database:mysql.default --bind php:php.default | |
wait_or_fail_for_port_to_listen $MMSN_PORT | |
} | |
function start_php() { | |
install_if_missing core/busybox-static netstat; | |
netstat -an | grep $PHP_PORT | grep LISTEN >/dev/null 2>/dev/null | |
if [ $? == 0 ]; then | |
echo "php is already running"; | |
return; | |
fi | |
hab svc load lancewf/php --strategy at-once | |
wait_or_fail_for_port_to_listen $PHP_PORT | |
} | |
function start_mysql() { | |
install_if_missing core/busybox-static netstat; | |
netstat -an | grep $MYSQL_PORT | grep LISTEN >/dev/null 2>/dev/null | |
if [ $? == 0 ]; then | |
echo "mysql is already running"; | |
return; | |
fi | |
hab svc load lancewf/mysql --strategy at-once | |
wait_or_fail_for_port_to_listen $MYSQL_PORT | |
} | |
function start_redis() { | |
install_if_missing core/busybox-static netstat; | |
netstat -an | grep $REDIS_PORT | grep LISTEN >/dev/null 2>/dev/null | |
if [ $? == 0 ]; then | |
echo "redis is already running"; | |
return; | |
fi | |
hab svc load lancewf/redis --strategy at-once | |
wait_or_fail_for_port_to_listen $REDIS_PORT | |
} | |
function start_auto_image_processer() { | |
hab svc load lancewf/auto_image_processer --strategy at-once | |
} | |
function failed_tests() { | |
n=$(journalctl -u hab | grep "whale-server-tests.default" | grep "Profile Summary" | awk '{ total += $12 } END { print total }') | |
if (( $n > 0 )); then | |
echo "$n controls failed" | |
show_failed_tests | |
else | |
echo "None failed" | |
fi | |
} | |
function show_failed_tests() { | |
journalctl -u hab | grep "whale-server-tests.default" | grep "×" | |
} | |
document "kill_running_service" <<DOC | |
This kills the running service. Where hab sup should restart. | |
DOC | |
function kill_running_service() { | |
install_if_missing core/busybox-static pgrep >/dev/null | |
SERVICE_PID=$(pgrep $1) | |
if [[ -n ${SERVICE_PID} ]]; then | |
kill $SERVICE_PID | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment