This repository has been archived by the owner on Dec 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add: install and startup script; read runtime config from .env.* files
- Loading branch information
Showing
4 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
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
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 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,4 +52,5 @@ node_modules | |
# .env | ||
.env | ||
.env.* | ||
!.env.example | ||
.ht* |
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
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!" |
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
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 |