Attempt to re-initialize if start fails.
This commit is contained in:
parent
d9fa6fdf33
commit
7b88673b36
16
start
16
start
|
@ -10,6 +10,18 @@ if ! test -f "$SCRIPT_DIR/.undercover_init_successful"; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
function may-init {
|
||||||
|
if $@; then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
echo "Service start failed. Re-initializing."
|
||||||
|
rm "$SCRIPT_DIR/.undercover_init_successful"
|
||||||
|
"$SCRIPT_DIR/init"
|
||||||
|
source "$SCRIPT_DIR/.venv/bin/activate"
|
||||||
|
$@
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
if ! pip3 -V | grep -E "$SCRIPT_DIR/\.?venv"; then
|
if ! pip3 -V | grep -E "$SCRIPT_DIR/\.?venv"; then
|
||||||
echo "Entering virtual environment..."
|
echo "Entering virtual environment..."
|
||||||
source "$SCRIPT_DIR/.venv/bin/activate"
|
source "$SCRIPT_DIR/.venv/bin/activate"
|
||||||
|
@ -23,9 +35,9 @@ fi
|
||||||
|
|
||||||
if [[ "$1" == "prod" ]]; then
|
if [[ "$1" == "prod" ]]; then
|
||||||
echo "Starting gunicorn production server..."
|
echo "Starting gunicorn production server..."
|
||||||
gunicorn -b "localhost:$PROD_PORT" "app:create_app()"
|
may-init gunicorn -b "localhost:$PROD_PORT" "app:create_app()"
|
||||||
else
|
else
|
||||||
echo "Starting local dev server..."
|
echo "Starting local dev server..."
|
||||||
export FLASK_APP=app
|
export FLASK_APP=app
|
||||||
flask --debug run --host=0.0.0.0
|
may-init flask --debug run --host=0.0.0.0
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue