Skip to content

Commit

Permalink
Fixed Loading environment variables while using Apache Fixes #439 (#441)
Browse files Browse the repository at this point in the history
* Changed how the settings variables are read into base.py. Just need to 'pip install python-dotenv' on the virtual environment on the server. Also deleted scripts because the one script is no longer needed.

* Added dependency to requirement.txt for python dot environment

* Created .env with default variables.

* ignores .env file

.env file can be customized to whoever is running Graphspace, no need to commit changes

* Added comments on how to format
  • Loading branch information
jddanna committed Feb 15, 2021
1 parent 854bb1e commit 3bd745d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 30 deletions.
5 changes: 5 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#lowercase false or true
IS_MAINTENANCE_SCHEDULED="false"
#start and end date/time can be formatted anyway
MAINTENANCE_START_DATETIME="1/1/2021 at 12:00PM"
MAINTENANCE_END_DATETIME="1/1/2021 at 12:00PM"
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ dist
build
venv
debug*

#environment variables
.env
9 changes: 6 additions & 3 deletions graphspace/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@

from sqlalchemy.ext.declarative import declarative_base

from dotenv import load_dotenv
import os
from elasticsearch import Elasticsearch

load_dotenv()

BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
ALLOWED_HOSTS = ['*']

Expand Down Expand Up @@ -161,6 +164,6 @@
}

MAINTENANCE = False
IS_MAINTENANCE_SCHEDULED = True if os.environ.get('IS_MAINTENANCE_SCHEDULED', "false") == "true" else False
MAINTENANCE_START_DATETIME = os.environ.get('MAINTENANCE_START_DATETIME', None)
MAINTENANCE_END_DATETIME = os.environ.get('MAINTENANCE_END_DATETIME', None)
IS_MAINTENANCE_SCHEDULED = True if os.getenv('IS_MAINTENANCE_SCHEDULED', "false") == "true" else False
MAINTENANCE_START_DATETIME = os.getenv('MAINTENANCE_START_DATETIME', None)
MAINTENANCE_END_DATETIME = os.getenv('MAINTENANCE_END_DATETIME', None)
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ elasticsearch-dsl>=5.0.0,<6.0.0
sphinx-rtd-theme
sphinx
recommonmark
python-dotenv==0.15.0
27 changes: 0 additions & 27 deletions scripts/schedule_maintenance.sh

This file was deleted.

0 comments on commit 3bd745d

Please sign in to comment.