MRGen is a monitoring and reporting tool. It is used to keep historical records based on Watchman Monitoring and RepairShopr services. It also generates reports for clients based on this historical data.
Developed and maintained by Sheldon Woodward for Out of a Jam Solutions.
Following are steps to setup the local development environemt. First clone the project and follow the steps to setup the front-end and back-end.
Environment variables are handled differently in devlopment and production. For
development, you can copy the .env.sample
file in the backend/
folder
and rename it to .env
. The environment variables that Django needs will be
set by Pipenv.
For the Django dev server, the only required environemnt variables are:
DJANGO_ENV
- Set toprod
for production ordev
to run in debug modeDJANGO_RDS
- Set toprod
to use MySQL ordev
to use SQLiteWATCHMAN_API_KEY
- The Watchman Monitoring API keyREPAIRSHOPR_API_KEY
- The RepairShopr API key
If you set DJANGO_RDS
to prod
then you will need to specify MySQL
connection details with the follwing environemt variables if they are not
the default values.
RDS_HOSTNAME
-127.0.0.1
- The MySQL server hostnameRDS_PORT
-3306
- The MySQL server portRDS_DB_NAME
-mrgen
- The MySQL server database nameRDS_USERNAME
-root
- The MySQL server userRDS_PASSWORD1
-password
- The MySQL server user's password
Also, you can speicify the host that Redis runs on if necessarry:
REDIS_HOSTNAME
-localhost
- The Redis server hostname
See the environment variables section below in the deployment section for details on production environment variables.
- Install the project dependencies
$ pipenv install
Sometimes installing the mysqlclient dependency will raise an error, use the following commands to get past this.
$ export LDFLAGS="-L/usr/local/opt/openssl/lib" $ export CPPFLAGS="-I/usr/local/opt/openssl/include"
- Migrate the database
$ pipenv run python manage.py migrate
- Start Redis
$ redis-server
- Start the celery worker process
$ pipenv run celery -A MRGen worker -l info
- Start the Beat process
$ pipenv run celery -A MRGen beat -l info --scheduler django_celery_beat.schedulers:DatabaseScheduler
- Start the Django server
$ pipenv run python manage.py runserver
- Change the current directory to the
frontend
folder
$ cd frontend
- Install the project dependencies
$ npm install
- Start the Vue web server and compiler
$ npm run serve
The development Django server is available by default at http://localhost:8000. The admin panel is available on /admin
and the API is available on /api
The development Vue web server is available be default at http://localhost:8080. The project is served on the root domain.
Following are steps to setup the production deployment environemt. First clone the project and follow the steps to deploy the application.
Environemnt variables for production deployment should be defined in a .env
in the project root. Docker Compose will use this centralized .env
file to
distribute the proper configuration to each part of the application.
The only environment variables that must be set are:
DJANGO_SECRET_KEY
- The secret key to prevent CSRFDJANGO_HOST_DOMAIN
- The domain name the site is running onDJANGO_URL
- The base url for the Django server used by VueVUE_URL
- The base url for the Vue server used by DjangoRDS_PASSWORD
- The password to use for the MySQL databaseWATCHMAN_API_KEY
- The Watchman Monitoring API keyREPAIRSHOPR_API_KEY
- The RepairShopr API key
Optionally, these other environemnt variables can be set but provide no real use excpet for custom setups or debugging:
IMAGE_TAG
-latest
- The tag for the MRGen Docker imageDJANGO_ENV
-prod
- Eitherprod
for production or anything else for non-productionDJANGO_RDS
-prod
- Eitherprod
for MySQL or anything else SQLiteRDS_DB_NAME
-mrgen
- The MRGen database nameRDS_USERNAME
-mrgen
- The database's non-root superuser
After setting up the .env
file, the container can be deployed with the
following command:
$ docker-compose up -d
Before the application is ready to be used, the database must be migrated. You can run the migrations with the following command:
$ docker-compose exec backend python manage.py migrate
If you already have an existing database, this command does not need to be run again unless the MRGen database configuration has changed.
Static files are automatically collected on the first run and build. After this,you will need to run the following command to collect static files into the Docker volume if they change or are updated:
$ docker-compose exec backend python manage.py collectstatic --noinput