2013-03-12 17:14:02 +04:00
Installation
2018-07-27 19:41:11 +03:00
============
2013-03-12 17:14:02 +04:00
2018-07-27 19:41:11 +03:00
```eval_rst
2015-12-09 20:11:55 +03:00
.. note:: This section describes how to set up a fully functioning
instance of Treeherder. If you only want to hack on the UI,
you can just setup a standalone webserver which accesses
the server backend using node.js, which is much simpler.
2018-07-26 19:02:36 +03:00
See the :doc:`UI development section < ui / installation > `.
2018-07-27 19:41:11 +03:00
```
2015-12-09 20:11:55 +03:00
2015-08-11 14:29:30 +03:00
Prerequisites
-------------
2014-09-09 00:18:09 +04:00
2018-07-27 19:41:11 +03:00
* If you are new to Mozilla or the A-Team, read the [A-Team Bootcamp].
* Install [Git], [Virtualbox] and [Vagrant] (latest versions recommended).
* Clone the [treeherder repo] from GitHub.
2016-05-31 22:43:48 +03:00
* Linux only: An nfsd server is required. You can install this on Ubuntu by running `apt-get install nfs-common nfs-kernel-server`
2013-03-12 17:14:02 +04:00
2014-09-09 00:18:09 +04:00
Setting up Vagrant
------------------
2015-08-11 18:00:49 +03:00
* Open a shell, cd into the root of the Treeherder repository, and type:
2013-03-12 17:14:02 +04:00
2018-07-27 19:41:11 +03:00
```bash
> vagrant up --provision
```
2013-03-12 17:14:02 +04:00
2018-05-14 13:04:17 +03:00
It will typically take 5 to 30 minutes for the vagrant provision to
2016-05-31 22:44:35 +03:00
complete, depending on your network performance. If you experience
2018-07-27 19:41:11 +03:00
any errors, see the [troubleshooting page ](troubleshooting.md ).
It is *very important* that the provisioning process complete successfully before
trying to interact with your test instance of treeherder: some things might
2016-05-31 22:44:35 +03:00
superficially seem to work a partially configured machine, but
2018-05-14 13:04:17 +03:00
it is almost guaranteed that some things *will break* in
2016-05-31 22:44:35 +03:00
hard-to-diagnose ways if vagrant provision is not run to completion.
2013-03-12 17:14:02 +04:00
2015-08-11 18:00:49 +03:00
* Once the virtual machine is set up, connect to it using:
2014-09-09 00:18:09 +04:00
2018-07-27 19:41:11 +03:00
```bash
> vagrant ssh
```
2013-03-12 17:14:02 +04:00
2015-06-01 18:42:46 +03:00
A python virtual environment will be activated on login, and the working directory will be the treeherder source directory shared from the host machine.
2013-03-12 17:14:02 +04:00
2018-07-27 19:41:11 +03:00
* For the full list of available Vagrant commands (for example, suspending the VM when you are finished for the day),
see their [command line documentation ](https://www.vagrantup.com/docs/cli/ ).
2015-08-11 14:12:32 +03:00
2018-07-27 19:41:11 +03:00
* If you just wish to [run the tests ](common_tasks.html#running-the-tests ),
you can stop now without performing the remaining steps.
2015-01-25 18:36:12 +03:00
2015-08-11 18:00:49 +03:00
Starting a local Treeherder instance
------------------------------------
2015-01-25 17:56:04 +03:00
2015-08-11 14:14:35 +03:00
* Start a gunicorn instance inside the Vagrant VM, to serve the static UI and API requests:
2014-09-09 00:18:09 +04:00
2018-07-27 19:41:11 +03:00
```bash
vagrant ~/treeherder$ ./bin/run_gunicorn
```
2013-03-12 17:14:02 +04:00
2015-08-11 18:00:49 +03:00
Or for development you can use the django runserver instead of gunicorn:
2014-09-09 00:18:09 +04:00
2018-07-27 19:41:11 +03:00
```bash
vagrant ~/treeherder$ ./manage.py runserver
```
2015-01-25 17:56:04 +03:00
2016-07-28 21:50:21 +03:00
this is more convenient because it automatically refreshes every time there's a change in the code.
2014-09-09 00:18:09 +04:00
2018-05-10 19:58:04 +03:00
* You must also start the UI dev server. Open a new terminal window and ``vagrant ssh`` to
2017-03-01 16:06:15 +03:00
the VM again, then run the following:
2018-07-27 19:41:11 +03:00
```bash
vagrant ~/treeherder$ yarn start:local
```
2017-03-01 16:06:15 +03:00
This will build the UI code in the ``dist/`` folder and keep watching for
2018-07-27 19:41:11 +03:00
new changes (See the [UI development section ](ui/installation.md ) for more ways to work with the UI code).
2017-03-01 16:06:15 +03:00
2018-07-27 19:41:11 +03:00
* Visit < http: // localhost:5000 > in your browser (NB: port has changed). Note: There will be no data to display until the ingestion tasks are run.
2014-09-09 00:18:09 +04:00
Running the ingestion tasks
---------------------------
2018-10-02 13:07:27 +03:00
Ingestion tasks populate the database with version control push logs, queued/running/completed jobs & output from log parsing, as well as maintain a cache of intermittent failure bugs. To run these:
2015-01-25 17:56:04 +03:00
2016-07-28 21:50:21 +03:00
* Start up a celery worker to process async tasks:
2013-07-17 21:38:13 +04:00
2018-07-27 19:41:11 +03:00
```bash
vagrant ~/treeherder$ celery -A treeherder worker -B --concurrency 5
```
2013-07-24 18:15:50 +04:00
The "-B" option tells the celery worker to startup a beat service, so that periodic tasks can be executed.
2015-01-25 17:56:04 +03:00
You only need one worker with the beat service enabled. Multiple beat services will result in periodic tasks being executed multiple times.
2013-06-29 17:36:53 +04:00
2018-10-02 13:07:27 +03:00
* Then in a new terminal window, run `vagrant ssh` again, and follow the steps from the [loading pulse data ](pulseload.md ) page.
2015-05-21 23:40:22 +03:00
Ingesting a single push (at a time)
-----------------------------------
2018-10-02 13:07:27 +03:00
```eval_rst
.. warning::
With the end of life of buildbot, this command is no longer able to ingest jobs.
For now after running it, you will need to manually follow the steps from the
:doc:`loading pulse data< pulseload > ` page.
```
2015-05-21 23:40:22 +03:00
Alternatively, instead of running a full ingestion task, you can process just
the jobs associated with any single push generated in the last 4 hours
2018-07-27 19:41:11 +03:00
([builds-4h]), in a synchronous manner. This is ideal for testing. For example:
2015-04-22 21:28:33 +03:00
2018-07-27 19:41:11 +03:00
[builds-4h]: http://builddata.pub.build.mozilla.org/buildjson/
2013-12-17 18:05:58 +04:00
2018-07-27 19:41:11 +03:00
```bash
vagrant ~/treeherder$ ./manage.py ingest_push mozilla-inbound 63f8a47cfdf5
```
2014-01-07 19:36:55 +04:00
2016-11-08 23:48:05 +03:00
If running this locally, replace `63f8a47cfdf5` with a recent revision (= pushed within
2015-08-04 20:00:54 +03:00
the last four hours) on mozilla-inbound.
2015-07-01 00:17:58 +03:00
2016-10-25 21:58:46 +03:00
Ingesting a range of pushes
---------------------------
It is also possible to ingest the last N pushes for a repository:
2018-07-27 19:41:11 +03:00
```bash
vagrant ~/treeherder$ ./manage.py ingest_push mozilla-central --last-n-pushes 100
```
2016-10-25 21:58:46 +03:00
In this mode, only the pushlog data will be ingested: additional results
associated with the pushes will not. This mode is useful to seed pushes so
they are visible on the web interface and so you can easily copy and paste
changesets from the web interface into subsequent ``ingest_push`` commands.
2015-08-11 14:29:30 +03:00
2018-07-27 19:41:11 +03:00
[A-Team Bootcamp]: https://ateam-bootcamp.readthedocs.io
[Git]: https://git-scm.com
[Vagrant]: https://www.vagrantup.com
[Virtualbox]: https://www.virtualbox.org
[treeherder repo]: https://github.com/mozilla/treeherder