Phlogiston/Installation

Operating System
These instructions assume installation of Phlogiston on a Debian GNU/Linux Stretch (9.5) system.

R
Install R repository to get the newest version (from DigitalOcean instructions)

As phlogiston, type  to enter R command line. In R,

Install locally if prompted.

A Postgres account for Phlogiston
Phlogiston requires a local account for file storage and calculation, and the local account must have access to a PostGreSQL database for data storage and reporting. This account should be isolated from all other functions

Superuser access is required to because load_tables.sql installs the intarray postgresql extension. This also allows the script to create or reset its own data tables. Probably don't do this on a shared server.

Access to Phlogiston directories for postgresql
The Phlogiston scripts run some commands on the postgresql server, which runs under the postgres user, which needs to have access to phlogiston directories via the phlogiston group.

Install Phlogiston
Get the phlogiston code by cloning it from github. As the phlogiston user:

Configure Nginx
Configure Nginx to publish from the phlogiston html output directory. Create the following file as /etc/nginx/sites-available/phlogiston:

And run these commands to configure Nginx to use it

Set up the reports home page
And edit index.html to reflect the scopes being reported.

Automate daily reports

 * 1) Run a complete reconstruction for all scopes:
 * 2) where xxx and yyy are reporting scopes.  Append as many   as needed.
 * 3) Create a cron job for the phlogiston user, of the form
 * 4) TODO: include virtual environment in script
 * 5) This runs daily at 4:15 am UTC.  Set this to be right after the dump is generated from Phabricator, and to run as often as the dump is updated.  (Phlogiston can take hours to run, so anything more than daily may not be practical without optimization.)
 * 6) The file   can be inspected for status.
 * 7) In particular,   will show one line per scope per reconstruction and/or report.
 * 1) The file   can be inspected for status.
 * 2) In particular,   will show one line per scope per reconstruction and/or report.

First run
where xxx is a correctly configured scope. Validate the results.

How to use on other Phabricator instances besides Wikimedia Foundation
Untested:

1) set up a dump script on Phabricator, like this one, to generate dumps like this one.

2) Customize  to point to the new dump file.