WSL/SLF GitLab Repository

README.md 3.25 KB
Newer Older
1
# Monitoring-Backend
2
3
4
5
6

Python software package that processes, filters and calibrate times
series environmental monitoring data. Serves the data in a dynamic
Django API.

7
## Important Information
8
9
10
11
12

WARNING: project/settings.py LINE 30 DEBUG setting should be False for
security reasons before production deployment. Leaving this setting at
True is only ok during testing and development.

13
## Application Configuration and Operation
14
15
16
17

For details on how to operate the GC-Net application, please see the
README documentation at gcnet/README.rst

18
## Installation
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41

This software requires Python 3.8 and Django, it was developed using
PyCharm IDE.

To install gcnet-backend follow these steps:

1.  Clone the gcnet-backend repo from Github:

        https://github.com/EnviDat/monitoring-backend.git

2.  Ensure PDM is installed on your system and pep528 support is
    enabled.

    <https://pdm.fming.dev/latest/usage/pep582/>

3.  Install the dependencies using PDM

    For example:

        pdm install

        As per PEP582, dependencies are located under __pypackages__

42
## Database Setup and .env Configuration
43
44
45
46

WARNING: Never commit the .env file to GitHub!

Create a .env file at project/.env and enter your secret key, port, and
47
48
database settings ("db" means database). A .env file must be added to
the "project" directory so that that database and NGINX server operate
49
50
51
52
53
securely and correctly. project/settings.py reads the values from this
.env file. This project was developed using a Postgres database. If
using a local Postgres database the port number will probably be 5432.

Official documentation on why it is critical to set and protect
54
SECRET_KEY:
55
56
<https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/#secret-key>

57
ALLOWED_HOSTS contains the IP or domain of the server.
58
This is set to '\*' during development automatically.
59
60
61
62

PORT is the port number used by the NGINX server in runserver.py

By default Django writes to the public schema of a Postgres database.
63
These settings should be entered in the DATABASE_xxx settings.
64
65
66

This application uses the MonitoringRouter in project/routers.py to
direct database operations to the correct schema. In your database make
67
68
69
sure to have a "lwf" schema in the database used in the LWF_DB_xxx
settings and a "gcnet" schema in the database used in the
GCNET_DB_xxx settings.
70
71
72
73
74

.env Configuration Template:

    SECRET_KEY=<secret key>

75
    ALLOWED_HOSTS='["<IP or Domain>", "<IP or Domain>"]'
76
    PROXY_PREFIX=<Optional URL prefix if required / served behind a proxy>
77
    LOG_LEVEL=<Log level for app printing to STDOUT>
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97

    DATABASE_NAME=<db_name>
    DATABASE_USER=<db_user>
    DATABASE_PASSWORD=<db_password>
    DATABASE_HOST=<localhost or IP address of server where DB is hosted>
    DATABASE_PORT=<5432 or whichever port is assigned to DB>

    LWF_DB_SCHEMA="-c search_path=lwf"
    LWF_DB_NAME=<db_name>
    LWF_DB_USER=<db_user>
    LWF_DB_PASSWORD=<db_password>
    LWF_DB_HOST=<localhost or IP address of server where DB is hosted>
    LWF_DB_PORT=<5432 or whichever port is assigned to DB>

    GCNET_DB_SCHEMA="-c search_path=gcnet"
    GCNET_DB_NAME=<db_name>
    GCNET_DB_USER=<db_user>
    GCNET_DB_PASSWORD=password
    GCNET_DB_HOST=<localhost or IP address of server where DB is hosted>
    GCNET_DB_PORT=<5432 or whichever port is assigned to DB>