Socorro Installation: Difference between revisions

From PSwiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 330: Line 330:


== Deploy the apps for production usage ==
== Deploy the apps for production usage ==
'''Install prerequisites'''


   > apt-get install supervisor rsyslog libapache2-mod-wsgi memcached
   > apt-get install supervisor rsyslog libapache2-mod-wsgi memcached
'''Setup directory structure'''


   > mkdir /etc/socorro
   > mkdir /etc/socorro
Line 342: Line 346:
   > chmod 2775 /home/socorro/primaryCrashStore /home/socorro/fallback
   > chmod 2775 /home/socorro/primaryCrashStore /home/socorro/fallback


Install Socorro for production
'''Install Socorro for production'''


   > cd /home/planeshift/socorro
   > cd /home/planeshift/socorro
Line 348: Line 352:


   (as root)
   (as root)
  > cd /home/planeshift/socorro
   > cp config/*.ini /etc/socorro/
   > cp config/*.ini /etc/socorro/
  edit /etc/socorro/collector.ini and uncomment these lines:
  wsgi_server_class='socorro.webapi.servers.ApacheModWSGI'
  fs_root='/home/socorro/primaryCrashStore'
  crashstorage_class='socorro.external.fs.crashstorage.FSDatedRadixTreeStorage'


To setup properly the configuration files you have two ways:
# Download the ones I used and modify as needed for your installation
# Ask the various app to generate the ini for you and then modify as needed for your installation


Generate your own /etc/socorro/collector.ini
Generate your own /etc/socorro/collector.ini
Line 361: Line 365:
   > python /data/socorro/application/socorro/collector/collector_app.py --admin.conf=/etc/socorro/collector.ini --admin.dump_conf=/tmp/c1.ini
   > python /data/socorro/application/socorro/collector/collector_app.py --admin.conf=/etc/socorro/collector.ini --admin.dump_conf=/tmp/c1.ini
   > cp /tmp/c1.ini /etc/socorro/collector.ini
   > cp /tmp/c1.ini /etc/socorro/collector.ini
The main important parameters for collector.ini are:
  wsgi_server_class='socorro.webapi.servers.ApacheModWSGI'
  (tells collector to run inside Apache)
  fs_root='/home/socorro/primaryCrashStore'
  (points to the directory where your disk storage is)
  crashstorage_class='socorro.external.fs.crashstorage.FSDatedRadixTreeStorage'
  (uses the new FSDatedRadixTreeStorage class which organizes files by date in the disk storage area)
IMPORTANT NOTE: all your processes should use the same crashstorage_class or they will not be able to find the files


Generate your own /etc/socorro/processor.ini
Generate your own /etc/socorro/processor.ini
Line 378: Line 395:
Generate your own /etc/socorro/middleware.ini
Generate your own /etc/socorro/middleware.ini


  > login as socorro user
  > export PYTHONPATH=/data/socorro/application:/data/socorro/thirdparty
   > python /data/socorro/application/socorro/middleware/middleware_app.py --admin.conf=/etc/socorro/middleware.ini --help
   > python /data/socorro/application/socorro/middleware/middleware_app.py --admin.conf=/etc/socorro/middleware.ini --help
   > python /data/socorro/application/socorro/middleware/middleware_app.py --admin.conf=/etc/socorro/middleware.ini --admin.dump_conf=/tmp/m1.ini
   > python /data/socorro/application/socorro/middleware/middleware_app.py --admin.conf=/etc/socorro/middleware.ini --admin.dump_conf=/tmp/m1.ini
   > edit /tmp/m1 and change: filesystem_class='socorro.external.fs.crashstorage.FSDatedRadixTreeStorage'
   > edit /tmp/m1 and change: filesystem_class='socorro.external.fs.crashstorage.FSDatedRadixTreeStorage'
   > comment out 'platforms', 'implementation_list' and 'service_overrides' variables as those are printed wrongly by the dumper
   > comment out 'platforms', 'implementation_list' and 'service_overrides' variables as those are printed wrongly by the dumper and will give an error while running the middleware app
 
'''Add your own product to the database'''
 
The default installation provides two sample products (WaterWolf, NightTrain) and some sample versions of those products. But most likely you want to add your own app to socorro. Here is what I did.
 
At the time of this writing there is a bug in https://github.com/mozilla/socorro/blob/master/socorro/external/postgresql/raw_sql/procs/add_new_product.sql
 
So you need to edit /home/planeshift/socorro/socorro/external/postgresql/raw_sql/procs/add_new_product.sql at line 28 this way:
 
  INSERT INTO products ( product_name, sort, rapid_release_version,
        release_name, rapid_beta_version )
  VALUES ( prodname, current_sort + 1, initversion,
        COALESCE(ftpname, prodname),rapid_beta_version);
 
basically rapid_beta_version was missing and causing an error in the execution of add_new_product() below.


Edit the database (as user planeshift)
Edit the database (as user planeshift)


   > psql -U planeshift -d breakpad
   > psql -U planeshift -d breakpad
  > INSERT INTO products VALUES ('PlaneShift','0.1','0.1','PlaneShift','0');
  > INSERT INTO product_versions VALUES (17,'PlaneShift','0.5','0.5.10','0.5.10',0,'0.5.10','2013-08-23','2013-12-23','f','Release','f','f',null);


  > DELETE from products where product_name='PlaneShift';
  > DELETE from product_versions where product_name='PlaneShift';
  > DELETE from releases_raw where product_name='PlaneShift';
  > DELETE from product_productid_map where product_name='PlaneShift';
  > DELETE from product_release_channels where product_name='PlaneShift';
 
   > SELECT add_new_product('PlaneShift', '0.5.10','12345','PlaneShift',1);
   > SELECT add_new_product('PlaneShift', '0.5.10','12345','PlaneShift',1);
   > SELECT add_new_release ('PlaneShift','0.5.10','Release',201305051111,'Windows',1,'release','f','f');
   > SELECT add_new_release ('PlaneShift','0.5.10','Release',201305051111,'Windows',1,'release','f','f');
   > select update_product_versions(200);  // generates products version info for older releases, 200 days.
   > select update_product_versions(200);  // generates products version info for older releases, 200 days.


Cronjobs for Socorro
The last line inserts the data into 'product_versions' table. The default update_product_versions() checks only the new releases within a 30 days timeframe from current date. But if you call it like: select update_product_versions(200) it will then do it for previous 200 days. In my case the release date was older than 30 days, so was not showing up in the web UI.
 
'''Cronjobs for Socorro'''
Socorro’s cron jobs are managed by crontabber. crontabber runs every 5 minutes from the system crontab.
 
   > cp scripts/crons/socorrorc /etc/socorro/
   > cp scripts/crons/socorrorc /etc/socorro/
  edit crontab -e
  > */5 * * * * socorro /data/socorro/application/scripts/crons/crontabber.sh


Start daemons
  edit crontab:
  > crontab -e
  */5 * * * * socorro /data/socorro/application/scripts/crons/crontabber.sh
 
'''Configure and start daemons'''
 
Copy default configuration files
 
   > cp puppet/files/etc_supervisor/*.conf /etc/supervisor/conf.d/
   > cp puppet/files/etc_supervisor/*.conf /etc/supervisor/conf.d/
The files provided with the standard install point to the old version of the apps, so you need to modify those as follows.
  > vi /etc/supervisor/conf.d/1-socorro-processor.conf
  command = /data/socorro/application/socorro/processor/processor_app.py --admin.conf=/etc/socorro/processor.ini
  > vi /etc/supervisor/conf.d/3-socorro-monitor.conf
  command = /data/socorro/application/socorro/monitor/monitor_app.py --admin.conf=/etc/socorro/monitor.ini
   > /etc/init.d/supervisor stop
   > /etc/init.d/supervisor stop
   > /etc/init.d/supervisor start
   > /etc/init.d/supervisor start


Configure Apache
'''Configure Apache'''
 
There are two ways you can run the apps.
# With Virtual hosts
# With Virutal Directories (this is what I've used)
 
In case you want to use Virtual Hosts, you can use this: (I DIDN'T TEST THIS)
 
   > cp puppet/files/etc_apache2_sites-available/{crash-reports,crash-stats,socorro-api} /etc/apache2/sites-available
   > cp puppet/files/etc_apache2_sites-available/{crash-reports,crash-stats,socorro-api} /etc/apache2/sites-available
In case you want to use Virtual Directories, you can use this:
  > vi /etc/apache2/apache2.conf
  add at the end of the file:
  Include socorro.conf
  > vi /etc/apache2/socorro.conf (new file)
  WSGIPythonPath /data/socorro/application:/data/socorro/application/scripts
  WSGIPythonHome /home/planeshift/socorro/socorro-virtualenv
  WSGIScriptAlias /crash-stats /data/socorro/webapp-django/wsgi/socorro-crashstats.wsgi
  WSGIScriptAlias /crash-reports /data/socorro/application/wsgi/collector.wsgi
  WSGIScriptAlias /bpapi /data/socorro/application/wsgi/middleware.wsgi
  RewriteEngine on
  Redirect /home/ /crash-stats/home/




Activate apache modules
'''Activate apache modules'''
 
   > a2enmod headers
   > a2enmod headers
   > a2enmod proxy
   > a2enmod proxy
Line 419: Line 494:
   > /etc/init.d/apache2 restart
   > /etc/init.d/apache2 restart


Set access rights on cache dir
'''Set access rights on cache dir'''
 
   > chmod -R 777 /data/socorro/webapp-django/static/CACHE/
   > chmod -R 777 /data/socorro/webapp-django/static/CACHE/


Create a screen startup file “launchScorro” that'll be used for the Socorro scripts:


  cd /home/planeshift/socorro
'''Configure WebAPP'''
  . socorro-virtualenv/bin/activate
 
   export PYTHONPATH=.
Edit configuration file: /data/socorro/webapp-django/crashstats/settings/local.py
  startup_message off
 
  autodetach on
   DEFAULT_PRODUCT = 'PlaneShift'
  defscrollback 10000
 
   termcap xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'
Edit /data/socorro/webapp-django/crashstats/settings/base.py for webapp user authentication database:
   screen -S processor python socorro/processor/processor_app.py --admin.conf=./config/processor.ini
 
   screen -S monitor python socorro/monitor/monitor_app.py --admin.conf=./config/monitor.ini
   'NAME': '/home/socorro/sqlite.crashstats.db'
  screen -S middleware python socorro/middleware/middleware_app.py --admin.conf=config/middleware.ini
 
  [NOT NEEDED as it runs inside Apache] screen -S collector python socorro/collector/collector_app.py --admin.conf=./config/collector.ini
   > cp /data/socorro/webapp-django/sqlite.crashstats.db /home/socorro
   > chown www-data:socorro /home/socorro/sqlite.crashstats.db
 
 
== Test each of the component ==
 
'''Generating a crash'''
 
The crash minidump should be generated by breakpad on the real app.
 
'''Uploading a crash'''
 
You can upload through the app and breakpad, but there is also another simpler way which you can use to test.
 
Edit /data/socorro/application/socorro/collector/throttler.py adding these lines to def throttle(self, raw_crash):
 


        # check if user submitted the crash with minidump_upload and adjust parameters accordingly
        if 'prod' in raw_crash:
            raw_crash['ProductName'] = raw_crash['prod']
        if 'ver' in raw_crash:
            raw_crash['Version'] = raw_crash['ver']


Minidump simulation
It just remaps those 2 parameters as those are different from breakpad to minidump_upload program.


   > cd /data/socorro/stackwalk/bin/
   > cd /data/socorro/stackwalk/bin/
   > ./minidump_upload -p Planeshift -v 0.5.12 6cc10361-c469-1504-1d91efef-7b8e750c.dmp http://194.116.72.94/crash-reports/submit
   > ./minidump_upload -p Planeshift -v 0.5.12 6cc10361-c469-1504-1d91efef-7b8e750c.dmp http://194.116.72.94/crash-reports/submit


'''Check if Collector receives your dump'''


Configure WebAPP
To be written


Edit configuration file: /data/socorro/webapp-django/crashstats/settings/local.py
'''Check if Monitor/Processor read the dump from disk '''
 
To be written


DEFAULT_PRODUCT = 'PlaneShift'
'''Check if the dump information lands in postgres'''


To be written


Access the web UI
'''Access the web UI'''


   http://194.116.72.94/crash-stats/home/products/WaterWolf
   http://194.116.72.94/crash-stats/home/products/WaterWolf
Line 488: Line 587:
   > cp /data/socorro/webapp-django/sqlite.crashstats.db /home/socorro
   > cp /data/socorro/webapp-django/sqlite.crashstats.db /home/socorro
   > chown www-data:socorro /home/socorro/sqlite.crashstats.db
   > chown www-data:socorro /home/socorro/sqlite.crashstats.db
== Other older notes, DO NOT consider ==
Create a screen startup file “launchScorro” that'll be used for the Socorro scripts:
  cd /home/planeshift/socorro
  . socorro-virtualenv/bin/activate
  export PYTHONPATH=.
  startup_message off
  autodetach on
  defscrollback 10000
  termcap xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'
  screen -S processor python socorro/processor/processor_app.py --admin.conf=./config/processor.ini
  screen -S monitor python socorro/monitor/monitor_app.py --admin.conf=./config/monitor.ini
  screen -S middleware python socorro/middleware/middleware_app.py --admin.conf=config/middleware.ini
  [NOT NEEDED as it runs inside Apache] screen -S collector python socorro/collector/collector_app.py --admin.conf=./config/collector.ini
Tweaking the database
  > INSERT INTO products VALUES ('PlaneShift','0.1','0.1','PlaneShift','0');
  > INSERT INTO product_versions VALUES (17,'PlaneShift','0.5','0.5.10','0.5.10',0,'0.5.10','2013-08-23','2013-12-23','f','Release','f','f',null);
If something goes wrong and you want to delete your product and versions
  > DELETE from products where product_name='PlaneShift';
  > DELETE from product_versions where product_name='PlaneShift';
  > DELETE from releases_raw where product_name='PlaneShift';
  > DELETE from product_productid_map where product_name='PlaneShift';
  > DELETE from product_release_channels where product_name='PlaneShift';

Revision as of 17:23, 28 August 2013

Overview

This guide illustrate how to install Socorro with the minimum components needed for a medium sized project. Socorro is used at Mozilla to manage thousands of crashes a day and spanning multiple applications. The full architecture allows distributed loads, throttling, queuing and other optimization techniques required for such a large amount of crashes per day. Medium size projects like PlaneShift, may use a simplified architecture, which is described in this installation guide.

This guide has been written in August 2013. I've used a Debian Squeeze (6.0.7) server.

The official reference documentation at this point is pretty minimal and not complete enough to succeed in the install, anyway if you want to have a look it's located here: http://socorro.readthedocs.org/en/latest/installation.html

The full architecture schema is here: http://socorro.readthedocs.org/en/latest/generalarchitecture.html

The architecture we are going to use is the following:

File:Socorro wo hbase2.png

Components

This section lists the components and their usage. There is a reference to their configuration files after you have "deployed for production" (this will be explained later). You don't need to read through all of this chapter now, but you can use it later on as a reference when you are troubleshooting.

Supervisor

Supervisor is the process which starts the needed components of Socorro, namely he starts Processor and Monitor. You can start and stop supervisor with:

> /etc/init.d/supervisor stop
> /etc/init.d/supervisor start
  • His configuration file is located in /etc/supervisor
  • The configuration files of the processes he starts are located in /etc/supervisor/conf.d
  • His log files are located in /var/log/supervisor/

Collector

  • This is the application which receives the dump file from your application. This is the first piece we would like to have working.
  • In our simplified install it runs inside apache, so it’s not started by supervisor. There are ways to have it run separately, but we are not interested in this type of configuration.
  • His main configuration file is /etc/socorro/collector.ini
  • The collector uses a filesystem to write the dumps to.
  • Running inside Apache, its log files are written in the apache logs: /var/log/apache2/error.log

CrashMover (DO NOT USE)

Crashmover is an additional component not used in our simplified install. Just forget about him and all related config files.

Just for reference, it's started by supervisor starting app is here: /data/socorro/application/scripts/newCrashMover.py real app is here: /data/socorro/application/socorro/storage

We may want to disable it (Need to understand how)

Monitor

Monitor polls the file system and then queues up the crashes in Postgres.

  • Monitor is started by supervisor
  • His main configuration file is /etc/socorro/monitor.ini
  • starting app is here: /data/socorro/application/socorro/monitor/monitor_app.py
  • real app is here: /data/socorro/application/socorro/monitor/monitor.py

Processor

Processor polls Postgres and consumes the job that Monitor just queued, also it uses the filesystem to process some data on the dumps.

  • Processor is started by supervisor
  • is main configuration file is /etc/socorro/processor.ini
  • starting app is here: /data/socorro/application/socorro/processor/processor_app.py
  • real app is here: /data/socorro/application/socorro/processor/processor.py

Middleware

Middleware is a layer of API which is called by the various components to execute their operations, in particular is used by the webapp UI to query the database.

  • Runs inside Apache with wsgi, so it's not started by supervisor
  • Real app is here : /data/socorro/application/socorro/middleware/middleware_app.py
  • Configuration file: /etc/socorro/middleware.ini
  • Running inside Apache, its log files are written in the apache logs: /var/log/apache2/error.log

Webapp

This is the UI you use to visualize the latest crashes and stacktraces.

  • Doesn't have a specific process running, as it's made of web pages calling the middleware
  • It's a Django application (you can google it).
  • Located here: /data/socorro/webapp-django
  • Configuration file: /data/socorro/webapp-django/crashstats/settings/base.py
  • Configuration file: /data/socorro/webapp-django/crashstats/settings/local.py


Directory structure

Before proceeding with the installation, it's important you understand the directory structure which will be created by the standard install, so you can troubleshoot more easily the installation if needed.

/home/planeshift/socorro

This is where I’ve checked out the sources and did the initial Socorro installation. Our project is called "planeshift" and our default user on that server was "planeshift" as well. This is the initial enviroment where everything gets built and tested. It's called the "development environment" as it's used for internal testing and not for production usage. When the installation is completed, you will deploy the necessary pieces to the other directories with the procedure "deploying in production" (see below). After the production deployment is done, none of the files (including configs) in this dir will be used anymore.

/etc/supervisor/conf.d

Contains supervisor ini files, like 1-socorro-processor.conf 2-socorro-crashmover.conf 3-socorro-monitor.conf

These scripts point the supervisor to execute the apps in /data/socorro/application/

/etc/socorro

Contains all .ini files like: collector.ini crashmover.ini monitor.ini processor.ini

/home/socorro

This is the primary storage location for uploaded minidumps, no configuration files are present

/data/socorro

Contains all applications as executed in the production environment

Please note there are configuration files under /data/socorro/application/config like collector.ini crashmover.ini monitor.ini processor.ini, but those are NOT used in the final install, as one step of the install is to copy those under /etc/socorro, where the final configuration files will reside.

/var/log/socorro

Contains the logs from the applications like Monitor and Processor.

/var/log/supervisor

Contains the log of the supervisor.

How to proceed

These are the steps we are going to follow for the installation:

  1. install all components as per Mozilla instructions
  2. deploy the components to the "production environment", which is nothing else than other directories
  3. Test and troubleshoot each of the component installed


Install all components

For this chapter we assume you just have a clean operating system install and none of the components is actually installed. In your case some of the components may already be there, just check the versions in case.

I've taken notes of the versions which were installed on my system. (the "Setting ..." lines)

Install build essentials

 > apt-get install build-essential subversion (already present)


Install python software

 > apt-get install python-software-properties
 Setting up python-apt-common (0.7.100.1+squeeze1) ...
 Setting up python-apt (0.7.100.1+squeeze1) ...
 Setting up iso-codes (3.23-1) ...
 Setting up lsb-release (3.2-23.2squeeze1) ...
 Setting up python-gnupginterface (0.3.2-9.1) ...
 Setting up unattended-upgrades (0.62.2) ...
 Setting up python-software-properties (0.60.debian-3) ...
 > apt-get install libpq-dev python-virtualenv python-dev
 Setting up libpython2.6 (2.6.6-8+b1) ...
 Setting up python2.6-dev (2.6.6-8+b1) ...
 Setting up python-dev (2.6.6-3+squeeze7) ...
 Setting up python-pkg-resources (0.6.14-4) ...
 Setting up python-setuptools (0.6.14-4) ...
 Setting up python-pip (0.7.2-1) ...
 Setting up python-virtualenv (1.4.9-3squeeze1) ...
 > apt-get install python2.6 python2.6-dev


Install postgres 9.2

In my case I was using Debian squeeze. On this release the default postgres is 8.4, which is too old to work with socorro because it doesn't have JSON support. So I needed to update the repos to have postgres 9.2

 Create /etc/apt/sources.list.d/pgdg.list and add this line:
 deb http://apt.postgresql.org/pub/repos/apt/ squeeze-pgdg main
 > wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -
 > sudo apt-get update
 > apt-get install postgresql-9.2 postgresql-plperl-9.2 postgresql-contrib-9.2 postgresql-server-dev-9.2

Ensure that timezone is set to UTC

 > vi /etc/postgresql/9.2/main/postgresql.conf
 timezone = 'UTC'
 > service postgresql restart

Install other needed components

 > apt-get install rsync libxslt1-dev git-core mercurial
 > apt-get install python-psycopg2
 > apt-get install libsasl2-dev


Add a new superuser account to postgres

(executed as root)

 > su - postgres -c "createuser -s planeshift"

Remove security layer for postgres (this is to avoid the PostgreSQL Error "FATAL: Peer authentication failed")

 Edit /etc/postgresql/9.2/main/pg_hba.conf and change the following line from 'peer' to 'trust':
 
 host    all         all         127.0.0.1/32          peer  
 host    all         all         127.0.0.1/32          trust
 > service postgresql restart


Download and install Socorro

(executed as planeshift)

 > cd
 > git clone --depth=1 https://github.com/mozilla/socorro socorro
 > cd socorro
 > git fetch origin --tags --depth=1
 > git checkout 56 (chosen release 56 as the stable one)

Node/Nmp is required, install it:

 > apt-get install openssl libssl-dev
 > git clone https://github.com/joyent/node.git
 > cd node
 > git tag
 > git checkout v0.9.12
 > ./configure --openssl-libpath=/usr/lib/ssl
 > make
 > make test
 > sudo make install
 > node -v # this line checks if its running!

Update python-pip (as root):

 > pip install --upgrade pip
 > /home/planeshift/socorro/socorro-virtualenv/bin/pip install --upgrade pip

Install lessc

 > npm install less -g

Install json_extensions for use with PostgreSQL

From inside the Socorro checkout

 > export PATH=$PATH:/usr/lib/postgresql/9.2/bin
 > make json_enhancements_pg_extension

Run unit/functional tests

From inside the Socorro checkout

 > make test

Install minidump_stackwalk

From inside the Socorro checkout

This is the binary which processes breakpad crash dumps into stack traces:

 > make minidump_stackwalk

Setup environment

 > make bootstrap-dev   (this line is needed only one time)

Everytime you want to run socorro commands you will have to:

 > . socorro-virtualenv/bin/activate
 > export PYTHONPATH=.
 > (execute here your command)

Populate PostgreSQL Database

as user root

 > cd socorro
 > psql -f sql/roles.sql postgres

as user planeshift

 > cd socorro
 > . socorro-virtualenv/bin/activate
 > export PYTHONPATH=.

You cannot start from an empty database, as there are multiple tables (example list of operating systems) which have to be populated for the system to work. For this reason you need to use --fakedata, which loads some of those tables together with some sample products (WaterWolf, NightTrain).

I don't remember which one of the two below worked, but it's one of the two, the other should give you an error:

 > ./socorro/external/postgresql/setupdb_app.py --database_name=breakpad --fakedata --dropdb --database_superusername=breakpad_rw --database_superuserpassword=bPassword
 > ./socorro/external/postgresql/setupdb_app.py --database_name=breakpad --fakedata --database_superusername=planeshift --dropdb

Create partitioned reports_* tables

Socorro uses PostgreSQL partitions for the reports table, which must be created on a weekly basis.

Normally this is handled automatically by the cronjob scheduler crontabber but can be run as a one-off:

 > python socorro/cron/crontabber.py --job=weekly-reports-partitions --force

I needed to run it as I was getting an error on Processor saying:

 ProgrammingError: relation "raw_crashes_20130826" does not exist
 LINE 1: insert into raw_crashes_20130826 (uuid, raw_crash, date_proc...

After running the command above, the table raw_crashes_20130826 was created.

Run socorro in dev mode

The dev mode is basically a version of socorro which runs only on the local server, launching the services manually, and running on ports 8882 and 8883. Usually you don't want this in production, but can be useful just to make a test if everything works.

Copy default config files

 > cp config/collector.ini-dist config/collector.ini
 > cp config/processor.ini-dist config/processor.ini
 > cp config/monitor.ini-dist config/monitor.ini
 > cp config/middleware.ini-dist config/middleware.ini

Run the apps

 > cd socorro
 > . socorro-virtualenv/bin/activate
 > export PYTHONPATH=.
 > screen -S processor python socorro/processor/processor_app.py --admin.conf=./config/processor.ini
 > screen -S monitor python socorro/monitor/monitor_app.py --admin.conf=./config/monitor.ini
 > screen -S middleware python socorro/middleware/middleware_app.py --admin.conf=config/middleware.ini
 > screen -S collector python socorro/collector/collector_app.py --admin.conf=./config/collector.ini


Deploy the apps for production usage

Install prerequisites

 > apt-get install supervisor rsyslog libapache2-mod-wsgi memcached

Setup directory structure

 > mkdir /etc/socorro
 > mkdir /var/log/socorro
 > mkdir -p /data/socorro
 > useradd socorro
 > chown socorro:socorro /var/log/socorro
 > mkdir -p /home/socorro/primaryCrashStore /home/socorro/fallback /home/socorro/persistent
 > chown www-data:socorro /home/socorro/primaryCrashStore /home/socorro/fallback /home/socorro/persistent
 > chmod 2775 /home/socorro/primaryCrashStore /home/socorro/fallback

Install Socorro for production

 > cd /home/planeshift/socorro
 > make install
 (as root)
 > cd /home/planeshift/socorro
 > cp config/*.ini /etc/socorro/

To setup properly the configuration files you have two ways:

  1. Download the ones I used and modify as needed for your installation
  2. Ask the various app to generate the ini for you and then modify as needed for your installation

Generate your own /etc/socorro/collector.ini

 > login as socorro user
 > export PYTHONPATH=/data/socorro/application:/data/socorro/thirdparty
 > python /data/socorro/application/socorro/collector/collector_app.py --admin.conf=/etc/socorro/collector.ini --help
 > python /data/socorro/application/socorro/collector/collector_app.py --admin.conf=/etc/socorro/collector.ini --admin.dump_conf=/tmp/c1.ini
 > cp /tmp/c1.ini /etc/socorro/collector.ini

The main important parameters for collector.ini are:

 wsgi_server_class='socorro.webapi.servers.ApacheModWSGI'
 (tells collector to run inside Apache)
 fs_root='/home/socorro/primaryCrashStore'
 (points to the directory where your disk storage is)
 crashstorage_class='socorro.external.fs.crashstorage.FSDatedRadixTreeStorage'
 (uses the new FSDatedRadixTreeStorage class which organizes files by date in the disk storage area)

IMPORTANT NOTE: all your processes should use the same crashstorage_class or they will not be able to find the files

Generate your own /etc/socorro/processor.ini

 > login as socorro user
 > export PYTHONPATH=/data/socorro/application:/data/socorro/thirdparty
 > python /data/socorro/application/socorro/processor/processor_app.py --admin.conf=/etc/socorro/processor.ini --help
 > chown www-data:socorro /home/socorro [NOT NEEDED? WAS root:root]
 > python /data/socorro/application/socorro/processor/processor_app.py --admin.conf=/etc/socorro/processor.ini --source.crashstorage_class=socorro.external.fs.crashstorage.FSDatedRadixTreeStorage --admin.dump_conf=/tmp/p1.ini
 > edit p1.ini file manually and delete everything inside [c_signature]
 > python /data/socorro/application/socorro/processor/processor_app.py --admin.conf=/tmp/p1.ini --admin.dump_conf=/tmp/p2.ini --destination.storage_classes='socorro.external.postgresql.crashstorage.PostgreSQLCrashStorage, socorro.external.fs.crashstorage.FSRadixTreeStorage'
 > edit p2.ini file manually and delete everything inside [c_signature]
 > python /data/socorro/application/socorro/processor/processor_app.py --admin.conf=/tmp/p2.ini --admin.dump_conf=/tmp/p3.ini --destination.storage1.crashstorage_class=socorro.external.fs.crashstorage.FSRadixTreeStorage
 > edit p3.ini file manually and delete everything inside [c_signature]
 > edit p3.ini and set fs_root=/home/socorro/primaryCrashStore . There should be two places, one under [destination]storage1 and one under [source] 

Generate your own /etc/socorro/middleware.ini

 > login as socorro user
 > export PYTHONPATH=/data/socorro/application:/data/socorro/thirdparty
 > python /data/socorro/application/socorro/middleware/middleware_app.py --admin.conf=/etc/socorro/middleware.ini --help
 > python /data/socorro/application/socorro/middleware/middleware_app.py --admin.conf=/etc/socorro/middleware.ini --admin.dump_conf=/tmp/m1.ini
 > edit /tmp/m1 and change: filesystem_class='socorro.external.fs.crashstorage.FSDatedRadixTreeStorage'
 > comment out 'platforms', 'implementation_list' and 'service_overrides' variables as those are printed wrongly by the dumper and will give an error while running the middleware app

Add your own product to the database

The default installation provides two sample products (WaterWolf, NightTrain) and some sample versions of those products. But most likely you want to add your own app to socorro. Here is what I did.

At the time of this writing there is a bug in https://github.com/mozilla/socorro/blob/master/socorro/external/postgresql/raw_sql/procs/add_new_product.sql

So you need to edit /home/planeshift/socorro/socorro/external/postgresql/raw_sql/procs/add_new_product.sql at line 28 this way:

 INSERT INTO products ( product_name, sort, rapid_release_version,
       release_name, rapid_beta_version )
 VALUES ( prodname, current_sort + 1, initversion,
       COALESCE(ftpname, prodname),rapid_beta_version);

basically rapid_beta_version was missing and causing an error in the execution of add_new_product() below.

Edit the database (as user planeshift)

 > psql -U planeshift -d breakpad
 > SELECT add_new_product('PlaneShift', '0.5.10','12345','PlaneShift',1);
 > SELECT add_new_release ('PlaneShift','0.5.10','Release',201305051111,'Windows',1,'release','f','f');
 > select update_product_versions(200);  // generates products version info for older releases, 200 days.

The last line inserts the data into 'product_versions' table. The default update_product_versions() checks only the new releases within a 30 days timeframe from current date. But if you call it like: select update_product_versions(200) it will then do it for previous 200 days. In my case the release date was older than 30 days, so was not showing up in the web UI.

Cronjobs for Socorro Socorro’s cron jobs are managed by crontabber. crontabber runs every 5 minutes from the system crontab.

 > cp scripts/crons/socorrorc /etc/socorro/
 edit crontab:
 > crontab -e
 */5 * * * * socorro /data/socorro/application/scripts/crons/crontabber.sh

Configure and start daemons

Copy default configuration files

 > cp puppet/files/etc_supervisor/*.conf /etc/supervisor/conf.d/

The files provided with the standard install point to the old version of the apps, so you need to modify those as follows.

 > vi /etc/supervisor/conf.d/1-socorro-processor.conf
 command = /data/socorro/application/socorro/processor/processor_app.py --admin.conf=/etc/socorro/processor.ini
 > vi /etc/supervisor/conf.d/3-socorro-monitor.conf
 command = /data/socorro/application/socorro/monitor/monitor_app.py --admin.conf=/etc/socorro/monitor.ini
 > /etc/init.d/supervisor stop
 > /etc/init.d/supervisor start

Configure Apache

There are two ways you can run the apps.

  1. With Virtual hosts
  2. With Virutal Directories (this is what I've used)

In case you want to use Virtual Hosts, you can use this: (I DIDN'T TEST THIS)

 > cp puppet/files/etc_apache2_sites-available/{crash-reports,crash-stats,socorro-api} /etc/apache2/sites-available

In case you want to use Virtual Directories, you can use this:

 > vi /etc/apache2/apache2.conf
 add at the end of the file:
 Include socorro.conf
 > vi /etc/apache2/socorro.conf (new file)
 WSGIPythonPath /data/socorro/application:/data/socorro/application/scripts
 WSGIPythonHome /home/planeshift/socorro/socorro-virtualenv
 WSGIScriptAlias /crash-stats /data/socorro/webapp-django/wsgi/socorro-crashstats.wsgi
 WSGIScriptAlias /crash-reports /data/socorro/application/wsgi/collector.wsgi
 WSGIScriptAlias /bpapi /data/socorro/application/wsgi/middleware.wsgi
 RewriteEngine on
 Redirect /home/ /crash-stats/home/


Activate apache modules

 > a2enmod headers
 > a2enmod proxy
 > a2enmod rewrite
 > /etc/init.d/apache2 restart

Set access rights on cache dir

 > chmod -R 777 /data/socorro/webapp-django/static/CACHE/


Configure WebAPP

Edit configuration file: /data/socorro/webapp-django/crashstats/settings/local.py

 DEFAULT_PRODUCT = 'PlaneShift'

Edit /data/socorro/webapp-django/crashstats/settings/base.py for webapp user authentication database:

 'NAME': '/home/socorro/sqlite.crashstats.db'
 > cp /data/socorro/webapp-django/sqlite.crashstats.db /home/socorro
 > chown www-data:socorro /home/socorro/sqlite.crashstats.db


Test each of the component

Generating a crash

The crash minidump should be generated by breakpad on the real app.

Uploading a crash

You can upload through the app and breakpad, but there is also another simpler way which you can use to test.

Edit /data/socorro/application/socorro/collector/throttler.py adding these lines to def throttle(self, raw_crash):


        # check if user submitted the crash with minidump_upload and adjust parameters accordingly
        if 'prod' in raw_crash:
            raw_crash['ProductName'] = raw_crash['prod']
       if 'ver' in raw_crash:
            raw_crash['Version'] = raw_crash['ver']

It just remaps those 2 parameters as those are different from breakpad to minidump_upload program.

 > cd /data/socorro/stackwalk/bin/
 > ./minidump_upload -p Planeshift -v 0.5.12 6cc10361-c469-1504-1d91efef-7b8e750c.dmp http://194.116.72.94/crash-reports/submit

Check if Collector receives your dump

To be written

Check if Monitor/Processor read the dump from disk

To be written

Check if the dump information lands in postgres

To be written

Access the web UI

 http://194.116.72.94/crash-stats/home/products/WaterWolf


Troubleshooting

Postgres useful commands:

 > /etc/init.d/postgresql start
 > /etc/init.d/postgresql stop
 > psql -U planeshift -d breakpad 
 breakpad# \dt (show tables)
 breakpad# \d products (describes table products)

1) http://194.116.72.94/crash-stats/home/frontpage_json?product=PlaneShift&versions=0.5.12 unable to open database file

Request Method: GET Request URL: http://194.116.72.94/crash-stats/home/frontpage_json?product=PlaneShift&versions=0.5.12 Django Version: 1.4.5 Exception Type: OperationalError Exception Value:

unable to open database file

Exception Location: /data/socorro/webapp-django/vendor/lib/python/django/db/backends/sqlite3/base.py in _sqlite_create_connection, line 278

Answer: this is for authenticated sessions, it does not need to be the socorro postgres db but needs to be somewhere with write access :) either sqlite db or postgres/mysql/anything django supports

Solution: edit /data/socorro/webapp-django/crashstats/settings/base.py for database setting

'NAME': '/home/socorro/sqlite.crashstats.db'

 > cp /data/socorro/webapp-django/sqlite.crashstats.db /home/socorro
 > chown www-data:socorro /home/socorro/sqlite.crashstats.db


Other older notes, DO NOT consider

Create a screen startup file “launchScorro” that'll be used for the Socorro scripts:

 cd /home/planeshift/socorro
 . socorro-virtualenv/bin/activate
 export PYTHONPATH=.
 startup_message off
 autodetach on
 defscrollback 10000
 termcap xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'
 screen -S processor python socorro/processor/processor_app.py --admin.conf=./config/processor.ini
 screen -S monitor python socorro/monitor/monitor_app.py --admin.conf=./config/monitor.ini
 screen -S middleware python socorro/middleware/middleware_app.py --admin.conf=config/middleware.ini
 [NOT NEEDED as it runs inside Apache] screen -S collector python socorro/collector/collector_app.py --admin.conf=./config/collector.ini


Tweaking the database

 > INSERT INTO products VALUES ('PlaneShift','0.1','0.1','PlaneShift','0');
 > INSERT INTO product_versions VALUES (17,'PlaneShift','0.5','0.5.10','0.5.10',0,'0.5.10','2013-08-23','2013-12-23','f','Release','f','f',null);

If something goes wrong and you want to delete your product and versions

 > DELETE from products where product_name='PlaneShift';
 > DELETE from product_versions where product_name='PlaneShift';
 > DELETE from releases_raw where product_name='PlaneShift';
 > DELETE from product_productid_map where product_name='PlaneShift';
 > DELETE from product_release_channels where product_name='PlaneShift';