Running and deploying QA Reports relies heavily on automated deployment scripts and version control repository. At high level, deployment process is following:
Capistrano enables you to automate also other administrative tasks like
To achieve all the goodness, you should set up the development environment on your workstation before continuing.
This guide has been written for vanilla Ubuntu 10.04 installation. You need to be logged in to the production server and have sudo rights to continue.
$ sudo aptitude install curl build-essential git-core openssh-server zlib1g-dev libssl-dev libreadline5-dev libcurl4-openssl-dev
$ bash < <(curl -B http://rvm.beginrescueend.com/install/rvm)
$ sudo adduser jakeskik rvm
$ source ~/.bashrc
$ rvm install ree
$ rvm use --default ree
$ gem install rails bundler --no-ri --no-rdoc#if you have proxy problem, plz refer to http://docs.rubygems.org/read/chapter/13#page51
Finally, enable rvm and Ruby Enterprise Edition to your deployment account, e.g. www-data
www-data's shell from
bash. You might want to change the home directory also from
/home/www-dataas shown below
$ sudo adduser www-data rvm $ sudo -iu www-data $ cp ~jakeskik/.profile . $ cp ~jakeskik/.bashrc . $ exit
$ sudo apt-get install apache2 apache2-prefork-dev libapr1-dev libaprutil1-dev $ gem install passenger --no-ri --no-rdoc $ rvmsudo passenger-install-apache2-module # Follow the on-screen instructions and edit apache.conf $ sudo service apache2 restart
$ sudo apt-get install mysql-server libmysqlclient-dev
QA Reports sends email notifications for system administrators (you) in case the application throws an exception. To enable notifications, there needs to be a mail server configured on the production host.
$ sudo apt-get install postfix
The default configuration is fine and allows only delivery for emails originated from localhost. Just click through the installer.
After installing the software, run a sanity check for the environment by creating a 'hello world' rails project and corresponding virtual host:
$ sudo -iu www-data $ rails new hello $ cd hello/public && pwd /home/www-data/hello/public $ exit
Write a following virtual host declaration to /etc/apache/sites-available/hello:
<VirtualHost *:80> ServerName hello.qa.leonidasoy.fi DocumentRoot /home/www-data/hello/public <Directory /home/www-data/hello/public> AllowOverride all Options -MultiViews </Directory> </VirtualHost>
Enable the virtual host
$ sudo a2ensite hello $ sudo service apache2 restart
Add the virtual host to
127.0.0.1 hello.qa.leonidasoy.fi # Use the same domain as above
Now you should be able to access the 'hello world' project with a browser, e.g. lynx
$ lynx hello.qa.leonidasoy.fi
$ mysql -u root -p mysql> create user 'qa-reports'@'localhost' identified by 'somepasswordofyourchoosing'; mysql> create database qa_reports_production character set 'utf8'; mysql> grant all privileges on qa_reports_production.* to 'qa-reports'@'localhost'; mysql> flush privileges; mysql> exit
Write a following virtual host declaration to /etc/apache/sites-available/qa-reports:
<VirtualHost *:80> ServerName qa-reports.qa.leonidasoy.fi DocumentRoot /home/www-data/qa-reports.meego.com/current/public <Directory /home/www-data/qa-reports.meego.com/current/public> AllowOverride all Options -MultiViews </Directory> </VirtualHost>
Enable the virtual host
$ sudo a2ensite qa-reports $ sudo service apache2 restart # Don't mind the warning about missing dir, # we'll deal with that one in a sec
QA Reports uses Capistrano to automate the deployments. The main benefit is to eliminate the risks of human errors and to enable easy and repeatable rollbacks. See Capistrano documentation for the details.
Capistrano is run from your development environment, so you should be now on your workstation with working QA Reports development environment to continue.
Set up public key authentication:
QA Reports uses following scripts to configure Capistrano
You might want to review all the files, but usually it's enough to update only config/deploy/production.rb according to your needs (servers, deployment account, ssh options). You can also create new deployment environment just by copying the production.rb, to e.g. internal.rb and modify it.
Once the Capistrano is updated according to your needs, run
$ cap production deploy:setup # or cap internal deploy:setup, if you created a new deployment environment
Setup command creates the folder hierarchy and the symbolic links required by Capistrano. During the setup it requests following information
Once the setup is complete, the deployment is as easy as it gets
$ cap production deploy:migrations
You should now have QA Reports up&running. Congrats!
git pull(In case there's changes in the deployment scripts)
cap production deploy:migrations
cap production deploy:rollback
If you have set up QA Dashboard you will most likely want to enable data synchronization to it:
If you need to export all your QA Reports data to your QA Dashboard you should use QA Reports' rake task. Once you have QA Reports up and running with correct QA Dashboard export setup, login to the production environment, go to folder your_installation/current and execute RAILS_ENV=production rake db:export_to_qadashboard.
Note: If you need to clear existing data from your QA Dashboard database, you will need to execute both db['qa-reports'].drop() and db['qa-reports'].dropIndexes() in the MongoDB database.
Edit nginx configuration installation_path/conf/nginx.conf: