Skip to content
This repository has been archived by the owner on Dec 26, 2021. It is now read-only.

Commit

Permalink
Add: install and startup script; read runtime config from .env.* files
Browse files Browse the repository at this point in the history
  • Loading branch information
rbeer committed Aug 22, 2019
1 parent ace9d1e commit dfd23ef
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ACCOUNT_FILE=./.htaccounts
LOG_FILE=./logs/results.log
DEBUG_FILE=./logs/debug.log
PORT=4040
MONGO_HOST=127.0.0.1
MONGO_PORT=27017
MONGO_DB=tester
MONGO_RESULTS_COLLECTION=results
MONGO_OVERSHOT_COLLECTION=overshot
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,5 @@ node_modules
# .env
.env
.env.*
!.env.example
.ht*
14 changes: 14 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

echo -n "Looking for Python3: "
if ! hash python3; then
echo -n "\nPlease install Python3 to use this program!"
fi
echo "OK"

echo "Installing dependencies..."
pip3 install -r requirements.txt --no-cache-dir

echo -e "\n----------------------------"
echo "All done! \o/"
echo "Run 'PYTON_ENV=[development|prodcution] ./run.sh' to start the server!"
23 changes: 23 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
if [ "$PYTHON_ENV" != 'production' ] && [ "$PYTHON_ENV" != 'development' ]; then
echo "Please provide a PYTHON_ENV value of 'production' or 'development'"
echo "e.g. $ PYTHON_ENV=development $0"
exit
fi


EXPECTED_ENV_FILE="./.env.$PYTHON_ENV"
if [ ! -f $EXPECTED_ENV_FILE ]; then
echo "Please provide a configuration file {$EXPECTED_ENV_FILE}!"
fi
echo "Using configuration from: $EXPECTED_ENV_FILE"
source $EXPECTED_ENV_FILE

echo "Starting server..."
python3 ./backend.py \
--account-file $ACCOUNT_FILE \
--log $LOG_FILE \
--debug $DEBUG_FILE \
--port "$PORT" \
--mongo-host $MONGO_HOST \
--mongo-port $MONGO_PORT \
--mongo-db $MONGO_DB

0 comments on commit dfd23ef

Please sign in to comment.