Deploying development environment by Vagrant

After downloading Gisquick source code, go to newly created gisquick directory and deploy virtual server providing Gisquick service.

Note

note Default configuration is stored in provision/group_vars/all file. Custom user configuration can be defined in provision/host_vars/gisquick. In this file can be optionally enabled Gisquick experimental mobile client by adding configuration variable as GISLAB_CLIENT_MOBILE: yes.

Virtual server can be deployed using vagrant command. This operation requires to install Vagrant, VirtualBox, and Ansible on host machine.

Note

note Minimum version of Ansible is 2.0 and higher, see instructions for installing software requirements in GIS.lab documentation.

To deploy virtual server run

$ vagrant up

Bringing machine 'gisquick' up with 'virtualbox' provider...
==> gisquick: Importing base box 'trusty-canonical-32'...
...
==> gisquick: Running provisioner: install (ansible)...
 gisquick: Running ansible-playbook...
...
PLAY RECAP *********************************************************************
gisquick                   : ok=4    changed=0    unreachable=0    failed=0

Tip

tip To speed up provisioning using Apt proxy server, set APT_PROXY variable before running above command like $ export APT_PROXY=http://192.168.99.118:3142. Check instructions how to set up Apt proxy server in GIS.lab documentation. Due to Apt proxy server repeated deployment of virtual server will be faster since software packages will retrieved from cache.

After successful deployment, new directories in source code tree are created:

dev
development directory
dev/cache
directory for caching map tiles
dev/publish
directory for QGIS projects publishing (this directory is crucial for Project publishing)

Created virtual machine can be accessed via ssh vagrant command (must be called also from source code root gisquick directory).

$ vagrant ssh

Welcome to Ubuntu 14.04.4 LTS (GNU/Linux 3.13.0-83-generic i686)

 * Documentation:  https://help.ubuntu.com/

 System information disabled due to load higher than 1.0

  Get cloud support with Ubuntu Advantage Cloud Guest:
    http://www.ubuntu.com/business/services/cloud


Last login: Wed Apr 13 08:49:28 2016 from X.X.X.X

Development services can be started using tmux-dev.sh command called from server prompt.

vagrant@gisquick:~$ /vagrant/utils/tmux-dev.sh

──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
System    check identified no issues (0 silenced).
May 01, 2016 - 22:17:09
Django version 1.8.9, using settings 'devproj.settings'
Starting development server at https://localhost:8000/
Using SSL certificate: /home/vagrant/.virtualenvs/gisquick/local/lib/python2.7/site-packages/sslserver/certs/development.crt
Using SSL key: /home/vagrant/.virtualenvs/gisquick/local/lib/python2.7/site-packages/sslserver/certs/development.key
Quit the server with CONTROL-C.

─────────────────────────────────────────────────────────────────────┬────────────────────────────────────────────────────────────────────
sudo tail             -n 0             -f /var/log/lighttpd/access.lo│sudo tail             -n 0             -f /var/log/lighttpd/qgis-map
g /var/log/lighttpd/error.log                                        │server.log
vagrant@gisquick:~$ sudo tail             -n 0             -f /var/│vagrant@gisquick:~$ sudo tail             -n 0             -f /var
log/lighttpd/access.log /var/log/lighttpd/error.log                  │/log/lighttpd/qgis-mapserver.log
==> /var/log/lighttpd/access.log <==                                 │
                                                                     │
==> /var/log/lighttpd/error.log <==                                  │
                                                                     │

[developme 0:servers*                                                                                         "gisquick" 20:17 01-May-16

Afterwards Gisquick can be accessed on https://localhost:8000.

../../_images/vagrant-screen.png

Tip

tip Use following command to run server tests from /vagrant/dev/django directory.

vagrant@gisquick:~$ python ./manage.py test webgis.viewer.tests

Note

note QGIS Mapserver is also forwarded to host machine on port 8090. Its logs can be found in /var/log/lighttpd directory.

Development services can be stopped from server terminal by tmux command.

vagrant@gisquick:~$ tmux kill-session

After logout, running virtual server can be shutdown by

vagrant@gisquick:~$ logout
$ vagrant halt

Halted machine can be launched again by vagrant up command.

Note

To destroy virtual machine and delete all related files type

$ vagrant destroy -f

Update environment

Go to source code tree and update Git repository

$ git pull

Then launch virtual machine by vagrant up and perform provision

$ vagrant provision

It is recommended to restart virtual machine

$ vagrant reload

before starting development services.

Note

note When there are fundamental changes, it is better to create virtual machine from scratch.

$ vagrant -f destroy
$ vagrant up

In this case vagrant provision command is not needed.

Tip

tip Quick update can be done with git pull command followed by running gulp build-web on server.

$ git pull && vagrant up && vagrant ssh
$ /vagrant/utils/tmux-dev.sh
$ cd /vagrant/clients
$ gulp build-web

User management

Log in to a virtual server by

$ vagrant ssh

Afterwards on the server enter Django shell

$ workon gisquick
$ python $HOME/deploy/www/manage.py shell

For creating a new user account, see User management section.

Tip

Virtual server provided by Vagrant comes with predefined vagrant user account. This account can be used for testing purposes. Password for this account is the same as the name, ie. vagrant.

Transferring project to publication server

Publication directory dev/publish is located in Gisquick source code tree from which virtual machine has been provisioned, see directory layout.

../../_images/vagrant-directory.svg

Figure 2: Publish directory for virtual server controlled by Vagrant.