Add sleep and help options to proxy start script
This commit is contained in:
parent
b2022fe687
commit
94ab55b6ab
@ -1,7 +1,67 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
while true
|
|
||||||
do
|
# How many seconds to sleep before starting the server again, unless it is explicitly specified
|
||||||
|
DEFAULT_SLEEP_SECONDS=3
|
||||||
|
|
||||||
|
function show_help {
|
||||||
|
local cmd=$0
|
||||||
|
|
||||||
|
echo "Create a start loop for the proxy server and optionally start a number of paper servers with it"
|
||||||
|
echo ""
|
||||||
|
echo "Usage: $cmd [OPTIONS]"
|
||||||
|
echo ""
|
||||||
|
echo "OPTIONS:"
|
||||||
|
echo " -s --sleep <secs> How many seconds to sleep after stopping the server"
|
||||||
|
# TODO options for paper servers
|
||||||
|
echo " -h --help Show this messasge"
|
||||||
|
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
function main {
|
||||||
|
|
||||||
|
local sleep_seconds=$DEFAULT_SLEEP_SECONDS
|
||||||
|
local help=false
|
||||||
|
|
||||||
|
# Parse arguments
|
||||||
|
local cmd=$0
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
local arg=$1
|
||||||
|
case "$arg" in
|
||||||
|
"--sleep" | "-s")
|
||||||
|
sleep_seconds=$2
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
"--help" | "-h")
|
||||||
|
help=true
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
err "Unknown argument: $arg"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if $help; then
|
||||||
|
show_help "$cmd"
|
||||||
|
fi
|
||||||
|
|
||||||
|
while true
|
||||||
|
do
|
||||||
|
echo "Starting proxy..."
|
||||||
./launch.sh
|
./launch.sh
|
||||||
echo sleeping...
|
echo "Sleeping for $sleep_seconds seconds..."
|
||||||
sleep 3
|
sleep "$sleep_seconds"
|
||||||
done
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Shows an error message and exits the program with code 1
|
||||||
|
#
|
||||||
|
# Usage: err <msg>
|
||||||
|
function err {
|
||||||
|
echo "$1"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
|
|
||||||
|
|||||||
8
start.sh
8
start.sh
@ -40,7 +40,7 @@ function main {
|
|||||||
local cmd=$0
|
local cmd=$0
|
||||||
|
|
||||||
# Parse arguments
|
# Parse arguments
|
||||||
while [ $# -gt 0 ]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
local arg=$1
|
local arg=$1
|
||||||
case "$arg" in
|
case "$arg" in
|
||||||
"--config" | "-c")
|
"--config" | "-c")
|
||||||
@ -118,7 +118,7 @@ function main {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if $help; then
|
if $help; then
|
||||||
show_help $cmd
|
show_help "$cmd"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Apply configuration
|
# Apply configuration
|
||||||
@ -163,9 +163,9 @@ function main {
|
|||||||
|
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
echo starting server...
|
echo "Starting server..."
|
||||||
./launch.sh
|
./launch.sh
|
||||||
echo sleeping...
|
echo "Sleeping for $sleep_seconds seconds..."
|
||||||
sleep "$sleep_seconds"
|
sleep "$sleep_seconds"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user