-
Notifications
You must be signed in to change notification settings - Fork 1
Deployment
Run the latest installation bash script in Ubuntu 16.04. Located here.
Before beginning, if you have a legacy data dump, you should have it handy.
Installation requires an internet connection.
-
Make it executable
chmod u+x install_metpetdb.sh -
Run as super user
sudo ./install_metpetdb.sh
The script is interactive and operates in the following stages:
(** -- user input required)
(^^ -- this may take a while)
(op -- an optional step)
- Create user metpetdb
- Update system packages (^^)
- Install additional required packages (^^)
- Install PostgreSQL
- Install PostGIS
- Setup PostgreSQL
- Setup PostGIS templates
- Create metpetdb databases
- metpetdb_legacy - for compatibility with older data dumps
- metpetdb - main database
- Set Postgres Password for the metpetdb user (**)
- This is the password used to connect to the metpetdb databases.
- The appropriate fields in api.env are automatically filled.
- Set ownership of metpetdb and metpetdb_legacy databases to metpetdb user
- Download latest codebase to /home/metpetdb/api
- Create the "api" virtual environment
- Install required Python packages
- Create "api.env" config
- Populate the legacy database from a data dump (op)
- Provide the absolute system path to the data dump. e.g /home/metpetdb/Desktop/metpetdb_may2017.dmp
- Perform data model migrations from Django to postgreSQL
- Perform data migrations from metpetdb_legacy to metpetdb database (**)(^^)(op)
- Collect static
- Setup Nginx (**)(op)
As the metpetdb user run:
source ~/.bashrc
After installation is completed, the api is located at /home/metpetdb/api.
EMAIL_HOST_USER: The email account used to send account activation and password reset emails.
EMAIL_HOST_PASSWORD: The corresponding EMAIL_HOST_USER password.
FRONT_END_URL: The url to the front end, prepended to account activation and password reset links.
To run the api
cd /home/metpetdb/api/metpetdb_api/
workon api
python manage.py runserver
The API should now be running and browsable at http://127.0.0.1:8000/
Ensure nginx is running
sudo service --status-all | grep nginx
should yield
[+] nginx
If not, run:
sudo service nginx restart
As the metpetdb user run:
start_api
Press enter to continue.
The API should now be running at <your_ip>/api
Security Note: When deploying the API on the production server, ensure that DEBUG is set to False in settings file
in API_SETTINGS. When debug is enabled, all environment variables are exposed, including those for the email host username and password.
Important Note: Ensure the secret key used in api.env matches the secret key used in the metpetdb interface.
As the metpetdb user run:
redeploy_api
The previous version of the API is kept on the server under the directory 'old_api'. The latest version of the API replaces the old and the existing api.env is retained.
Next, restart the server
sudo reboot now
Finally, reconnect to the server and restart the API
start_api
-
Installation failed during PostgreSQL setup
- Likely caused by a version compatibility issue with the installation script
- Before running the script:
sudo apt-get install postgresql-9.5-postgis-2.2 postgresql-9.5-postgis-scripts
-
Installation failed during data migrations, database corrupted during install, etc.
-
Delete the database and try running the installation script again
As the metpetdb user:
dropdb metpetdb dropdb metpetdb_legacy sudo ./install_metpetdb.sh
-
-
Email configuration with Gmail:
- Enable access to less secure apps in Gmail.
- Untrusted sign-in attempt
- you may need to sign in on the server to verify Gmail account ownership
- w3m may be useful if using ssh.
-
Cannot find commands
workon,start_api,redeploy_apietc.-
As the metpetdb user:
source ~/.bashrc
-
- Remove existing
start_api()andredeploy_api()commands from the.bashrc, before appending new version of these commands. - Uninstallation script / flag