An example monitoring application deriving from the jobmonitor
.
Clone the repository, set up a virtualenv
(with virtualenvwrapper
), generate some data, then run the application.
$ git clone https://github.com/alexpearce/example-monitoring-app.git
$ cd example-monitoring-app
$ mkvirtualenv monitoring-app
$ pip install -r requirements.txt
$ cd monitoring_app/static/files
$ python generate_histograms.py
$ cd ../../..
$ honcho start
The honcho start
command will initialise the application, a Redis server, and one worker.
To start more than one worker, you can use the -c
option like honcho start -c worker=4
.
A Redis server is used to queuing jobs and storing their results. ROOT is used to perform the tasks, namely getting data out of histograms, and to generate the data in the first place.
Running locally is all well and good, but ideally you will want a uniform development environment across your team, and parity between your development and production environments.
A nice way of doing this is to run the application on a virtual machine (VM) which mirrors the production environment. This example application can be run on a Scientific Linux 6.4 VM which is managed by Vagrant. Once you have installed Vagrant, the VM can be set up by running the following commands inside this repository.
# Run the initial provision
$ vagrant up --provision
# Run the second provisioning once prompted to do so
$ vagrant reload --provision
# One final reboot
$ vagrant reload
You can then SSH in to the machine and run the set up script, which installs the example application's dependencies.
# On the host machine
$ vagrant ssh
# Now on the VM
$ cd /vagrant
$ ./setup_monitoring_app.sh
To run the application, activate the virtualenv
and start the web server, worker instances, and Redis database using the Honcho process manager.
$ cd /vagrant
$ workon monitoring_app
$ honcho start -c worker=4
You can the view the example application on the host.