Skip to content
Rizky Maulana Nugraha edited this page Nov 24, 2016 · 1 revision

Welcome to the inasafe-django wiki!

Deployment Notes

InaSAFE Realtime Django works together closely with InaSAFE Realtime Processors. To deploy and start Inasafe Realtime Processors, follow Deployment Notes here: Docker Realtime Orchestration Notes. InaSAFE Realtime Processors needs to be running first.

Run all make commands from [root]/deployment dir of the repo.

Stopping containers

To stop all the containers and make sure all were dead.

make kill

Deploy/Starting basic containers

To run all basic containers needed by the services:

make run

This will start internal services like postgis, nginx, django, and several others. However, due to the nature that sometimes django run first than postgis, it can't found the database and/or database failed to start properly. To check this, check dblogs and make sure it is attached (hanging until you press CTRL+C).

make dblogs

This will display postgis database logs in attached view. The process should hang, leaving a prompt blinking at the end and continue to display more log messages as they appear. Usually, it hangs at this point:

------------------------------------------------------------------
Showing db logs in production mode
------------------------------------------------------------------
2016-11-01 10:42:00 UTC LOG:  database system was shut down at 2016-11-01 10:42:00 UTC
2016-11-01 10:42:00 UTC LOG:  MultiXact member wraparound protections are now enabled
2016-11-01 10:42:00 UTC LOG:  autovacuum launcher started
2016-11-01 10:42:00 UTC LOG:  database system is ready to accept connections
backend> backend> Postgis Already There
HSTORE is only useful when you create the postgis database.
/start-postgis.sh: line 89: [[]: command not found
                                 List of databases
       Name       |  Owner   | Encoding  | Collate | Ctype |   Access privileges   
------------------+----------+-----------+---------+-------+-----------------------
 gis              | docker   | UTF8      | C       | C     | 
 postgres         | postgres | SQL_ASCII | C       | C     | 
 template0        | postgres | SQL_ASCII | C       | C     | =c/postgres          +
                  |          |           |         |       | postgres=CTc/postgres
 template1        | postgres | SQL_ASCII | C       | C     | =c/postgres          +
                  |          |           |         |       | postgres=CTc/postgres
 template_postgis | postgres | UTF8      | C       | C     | 
(5 rows)

Postgres initialisation process completed .... restarting in foreground
2016-11-01 10:42:10 UTC LOG:  database system was interrupted; last known up at 2016-11-01 10:42:00 UTC
2016-11-01 10:42:11 UTC LOG:  database system was not properly shut down; automatic recovery in progress
2016-11-01 10:42:11 UTC LOG:  record with zero length at 0/20E2CC40
2016-11-01 10:42:11 UTC LOG:  redo is not required
2016-11-01 10:42:11 UTC LOG:  MultiXact member wraparound protections are now enabled
2016-11-01 10:42:11 UTC LOG:  autovacuum launcher started
2016-11-01 10:42:11 UTC LOG:  database system is ready to accept connections

If it says database ready, then everything is okay. Press CTRL+C to exit log view. However if log view were exited without you pressing CTRL+C, then postgis ends prematurely. You need to do make run again to start postgis again, until the logs says it is ready to accept connections.

This step of checking postgis is important. Sometimes the site shows Internal Server Error, just because postgis is dead. Check back this step if that occured again.

After you make sure Postgis running, check the website (for example, http://realtime.inasafe.org). If the page displayed correctly, the site is running correctly. If not, do these additional steps:

It is possible that staticfiles were not compiled correctly, or database were not migrated properly. Do these things:

make migrate
make collectstatic
make reload

This will migrate databases, compile staticfiles and reload uwsgi container. After this, check the website again. If error still occured, check back postgis.

Starting worker

InaSAFE Realtime Django have two kinds of celery worker. The first one is used to connect to InaSAFE Realtime Processor. The second one is used for internal monitoring services, called indicator.

Starting InaSAFE Worker

make inasafe-worker

To view the logs (Attached view, press CTRL+C to close log view)

make inasafe-worker-logs

Starting InaSAFE Realtime Django Indicator

make indicator-worker

To view the logs (Attached view, press CTRL+C to close log view)

make indicator-worker-logs

To know that InaSAFE Realtime Django and InaSAFE Realtime Processor were connected properly. Check the indicator page in InaSAFE Realtime (for example: http://realtime.inasafe.org/realtime/indicator). All indicators should be green and showing Healthy status. Especially, indicator called "Broker Connection Status". If this indicator is red, then check back that all the worker is started properly or start the worker again.