Deploying ChiliProject on Tomcat

Posted by attackofzach on Jan 22, 2012 10:42 AM EDT
attackofzach; By Zach Pratt
Mail this story
Print this story

I recently discovered ChiliProject, which is a fork of the Redmine project, and thought I’d take it for a spin. While Redmine project is very stable, it is a little slow to implement new functionality. That appears to be the primary reason for the ChiliProject fork. After browsing through their documentation and doing some google digging, I noticed that there is little to no information on how to deploy ChiliProject to Tomcat. I thought I’d take the time to try to fill the gap a little. It is my hope that this guide will serve as a reference for those of you who are working in primarily Tomcat-oriented shops, but are interested in test driving a high quality ruby-based app without having to setup the required apache+passenger (or nginx+passenger) infrastructure.

We have been using Redmine as our project management tool of choice at work for about a year and half. We use it primarily to manage our Pentaho and data warehouse implementation, along with some smaller initiatives. It meets our needs quite well by allowing us to host multiple projects (unlike Trac) with different needs on the same deployment. I love how flexible and easy it is to configure, however, I also like to keep my eyes open for potential alternatives. The last time I upgraded our Redmine installation, I decided to deploy Redmine on our Tomcat environment in an attempt to avoid having to maintain a apache+passenger install purely for Redmine (most of the apps we host are java based, so my Tomcat skills are much more polished than my apache+passenger skills).

I recently discovered ChiliProject, which is a fork of the Redmine project, and thought I’d take it for a spin. While Redmine project is very stable, it is a little slow to implement new functionality. That appears to be the primary reason for the ChiliProject fork. After browsing through their documentation and doing some google digging, I noticed that there is little to no information on how to deploy ChiliProject to Tomcat. I thought I’d take the time to try to fill the gap a little. It is my hope that this guide will serve as a reference for those of you who are working in primarily Tomcat-oriented shops, but are interested in test driving a high quality ruby-based app without having to setup the required apache+passenger (or nginx+passenger) infrastructure.

This guide assumes that you already have the following knowledge:

Basic shell skills How to setup and secure a mysql server How to setup and secure a tomcat server I developed this guide on a Fedora 16 installation at home, but I am confident that it will work just as well with CentOS, Scientific Linux, or any other RHEL derivative. You can also swap the package names for your favorite non-RedHat Linux distribution.

Required software packages: tomcat6 java-1.6.0-openjdk mysql-server Recommended software packages: tomcat6-admin-webapps tomcat6-webapps Files to download: chiliproject-2.6.0.tar.gz – https://www.chiliproject.org/projects/chiliproject/files JRuby 1.6.5.1 Binary .tar.gz – http://jruby.org/download Installing JRuby A JRuby installation is only needed to provide an initial environment for configuring and testing the web application. Once we deploy the chiliproject war to Tomcat, our JRuby installation will only be needed for subsequent upgrades or installing and testing plugins. Consequently, I don’t bother installing any official JRuby packages. Here is my barebones installation process:

If you don’t already have a bin directory in your home directory, create one: cd ~/. mkdir bin Extract the JRuby tarball to your newly created bin directory: cd bin tar -xzf ~/Downloads/jruby-bin-1.6.5.1.tar.gz Add the JRuby bin directory to your path: cd jruby-1.6.5.1/bin export PATH=${PATH}:${PWD} Initial ChiliProject install Go back to your bin directory and extract the chiliproject tarball: cd ~/bin/ tar -xzf ~/Downloads/chiliproject-2.6.0.tar.gz chiliproject uses bundler to manage the gems it depends on, so let’s install bundler: cd ~/bin/chiliproject-2.6.0 jruby -S gem install -r bundler The stock Gemfile assumes you’re going to run this on a native ruby installation. This causes a problem when it tries to install rmagick. Edit the Gemfile to replace rmagick with rmagick4j. Edit the following lines: group :rmagick do   gem “rmagick”, “>= 1.15.17? to match: group :rmagick4j do   gem “rmagick4j”, “>= 0.3.7? Install the required gems with bundler: jruby -S bundle install –without test development Create the chiliproject database: mysql -u root -h localhost -p create database chiliproject character set utf8; create user ‘chiliproject’@'localhost’ identified by ‘password’; grant all privileges on chiliproject.* to ‘chiliproject’@'localhost’; Copy the database.yml.example to database.yml cd ~/bin/chiliproject-2.6.0/config cp database.yml.example database.yml Edit the production section of the database.yml file with your favorite editor. The key change for a tomcat deployment is to make sure that the adapter property is set to jdbcmysql and not mysql. Here’s a copy of mine: production:   adapter: jdbcmysql   database: chiliproject   host: localhost   username: chiliproject   password: password   encoding: utf8 Copy the configuration.yml.example to configuration.yml cp configuration.yml.example configuration.yml Generate the session store: jruby -S bundle exec rake generate_session_store Start mysql (as root): service mysqld start Define the application’s mysql objects using rake db:migrate: RAILS_ENV=production jruby -S bundle exec rake db:migrate Load the default installation data: RAILS_ENV=production jruby -S bundle exec rake redmine:load_default_data Test the initial installation on the rails webrick server before moving forward: cd ~/bin/chiliproject-2.6.0 RAILS_ENV=production jruby -S script/server -e production Additional steps for final tomcat deployment Install warbler: jruby -S gem install -r warbler Create a warbler configuration: jruby -S warble config Edit the warbler configuration cd ~/bin/chiliproject-2.6.0 vim config/warble.rb Uncomment and change config.dirs to match the following: config.dirs = %w(app config lib log vendor tmp extra files lang) Uncomment and change config.gems to match the following: config.gems += ["activerecord-jdbcmysql-adapter", "jruby-openssl", "i18n", "rack"] Uncomment and change config.jar_name to match the following: config.jar_name = “chili” Uncomment the runtimes configuration to match the following: config.webxml.jruby.max.runtimes = 4 Install a specific version of the jruby-rack library: jruby -S gem install -r -v=1.0.9 jruby-rack jruby -S gem uninstall jruby-rack -v=1.1.3 Note: I have had issues with the 1.1.x jruby-rack library. After deployment, you’ll get an exception complaining about a call to raw_post. The same error does not occur when using the 1.0.x version of jruby-rack, hence the need to install an older version. Build the war file: cd ~/bin/chiliproject-2.6.0 jruby -S warble Prepare a folder for deploying the webapp (as root): cd /var/lib/tomcat6/webapps mkdir chili Extract the chili.war file to the new webapp directory (as root): cd /var/lib/tomcat6/webapps/chili unzip -q <user home>/bin/chiliproject-2.6.0/chili.war Set the proper permissions on the chili webapp directory (as root): cd /var/lib/tomcat6/webapps chown -R tomcat:tomcat chili/ Start tomcat (as root): service tomcat6 start Start a browser and test your deployment by going to the following URL: http://localhost:8080/chili/

Other notes For reference purposes, here are the gems that I installed at the time that I wrote this article (using jruby -S gem list –local):

*** LOCAL GEMS ***

actionmailer (2.3.14) actionpack (2.3.14) activerecord (2.3.14) activerecord-jdbc-adapter (1.2.1) activerecord-jdbcmysql-adapter (1.2.1) activerecord-jdbcpostgresql-adapter (1.2.1) activerecord-jdbcsqlite3-adapter (1.2.1) activeresource (2.3.14) activesupport (2.3.14) bouncy-castle-java (1.5.0146.1) bundler (1.0.21) coderay (0.9.8) fastercsv (1.5.4) i18n (0.4.2) jdbc-mysql (5.1.13) jdbc-postgres (9.0.801) jdbc-sqlite3 (3.7.2) jruby-jars (1.6.5.1) jruby-openssl (0.7.4) jruby-rack (1.0.9) json (1.6.5 java) net-ldap (0.2.2) rack (1.1.3) rails (2.3.14) rake (0.9.2.2, 0.8.7) rdoc (3.12) rmagick4j (0.3.7) ruby-openid (2.1.8) rubytree (0.5.3) rubyzip (0.9.5) sources (0.0.1) warbler (1.3.2)

Full Story

  Nav
» Read more about: Story Type: Tutorial; Groups: Fedora, Linux

« Return to the newswire homepage

This topic does not have any threads posted yet!

You cannot post until you login.