aboutsummaryrefslogtreecommitdiffstats
path: root/notes/INSTALL
blob: 7287aa3d3f9e2c5d50b8b9de1fba4ca0f18e81f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
Installing FixMyStreet
======================

mySociety applications have generally been run on Debian systems. Other Linux
distributions (and more) may well work but may also require some tweaking.

Clone the repository (you've probably already done this):
    git clone git://github.com/mysociety/fixmystreet.git
and be sure to run:
    git submodule update --init
inside to fetch the shared commonlib submodule.

conf/packages is a list of Debian packages that are needed, so install them if
you're on Debian/Ubuntu. You'll also probably need to install lots of CPAN
modules, see the section on that below.

FixMyStreet expects a PostgreSQL database with the postGIS extension, so set one
of them up - the schema is available in db/schema.sql. You will also need to load
in db/alert_types.sql to populate the alert types table.

Copy conf/general-example to conf/general and set it up appropriately:
* provide the relevant database connection details
* the OPTION_BASE_URL to be where your test site will run - eg 'http://localhost'
* set OPTION_UPLOAD_CACHE and OPTION_GEO_CACHE to your preferred values
* MAP_TYPE - OSM is probably the best one to try to start with, it's being
  successfully used.

Environment setup
-----------------

There is a little script that is used to set up the correct environment needed
for FMS to run (perl library paths, cpan install locations, bin paths etc). It
should be eval-ed in a bash shell to set environment variables:
   eval `./setenv.pl`

Cron scripts can be run through the bin/cron-wrapper script in order to be run
within the right environment.

CPAN module dependencies
------------------------

There are many CPAN dependencies that should be dealt with using
module-manage.pl which takes care of fetching specific versions of packages
from CPAN and building them. To install all the CPAN packages needed:

    eval `./setenv.pl`
    module-manage.pl setup

Look in the perl-external directory for details. Notably the following are important:

urls.txt    - url to the specific packages to fetch
modules.txt - list of all modules that need to be built
minicpan/   - local subset of cpan - used as source for all packages
local-lib   - where the cpan modules get built to
lib         - some initial modules needed for bootstrap
bin         - scripts to make it all work

Read the perl-external/bin/module-manage.pl code to see how it all works. It is
basically a wrapper around cpanm (which builds the packages) and dpan (which
helps maintain the fake cpan subset).

If you need to add a module do it using:

    module-manage.pl add Module::To::Add
  
and it will update all the relevant bits.

If a module won't build (Test::WWW::Mechanize and HTTP::Server::Simple fail
tests for me but the failures are not pertinent) then the module-manage script
will bail out. Look in ~/.cpanm/build_log to see what went wrong. You can force
an install if the test failures are not important by running cpanm directly:

    cpanm                                                   \
        --mirror /absolute/path/to/perl-external/minicpan   \
        --mirror-only                                       \
        --force                                             \
        Test::WWW::Mechanize

Hopefully once it is all built we can automate the running of module-manage.pl
in order to make sure that the setup is current.

Note: Others are starting to work on this and it might be a good idea to switch
to their output:
http://blogs.perl.org/users/sebastian_willert/2011/03/how-i-distribute-my-projects.html

Running the code
================

Development
-----------

Start the catalyst dev server using:

  CATALYST_DEBUG=1 ./script/fixmystreet_app_server.pl -r

CATALYST_DEBUG turns on the very verbose debug output which is helpful to see what the code is actually doing. The '-r' flag watches for files to change and then restarts the dev server.

Production
----------

mySociety currently use Apache, our httpd.conf performs a few redirect checks
and then passes everything else to the Catalyst app using FastCGI. Other
options are available with Catalyst, including PSGI, mod_perl, and so on.

What's where in the code?
=========================

FixMyStreet::App is a fairly standard Catalyst app; there aren't any really big
surprises.

Note that the FixMyStreet.pm file is used though to abstract some config
related things. The FixMyStreet->test_mode(1) which will do things like send
all emails to a memory queue for the test scripts. test_mode should only be
used in test scripts, and so is different from setting STAGING to true.

Testing
=======

There are several tests in the t directory - organized into subdirs. Note that
there is a module FixMyStreet::TestMech that abstracts some things like logging
in as a user and grabbing all the form error messages. This makes testing much
slicker and less fiddly.

Run all the tests (within the correct environment) using:

  prove -lr t

or a specific test in verbose mode using:

  prove -lv t/app/controller/report_new.t

For all the lovely options do 'prove --help'. Note I've made no attempt to make
the tests be able to run in parallel, the database fiddling would not be worth
it. The tests currently assume MAPIT_URL is set to the UK version.