Skip to content

ASI Installation Guide (rails 2)

randomm edited this page Sep 9, 2011 · 2 revisions

ASI installation guide

PLEASE NOTE THAT THESE INSTRUCTIONS ONLY REFER TO ASI RUNNING ON RAILS 2 (v2.3.8), CLONE CODE FROM THE RAILS2 BRANCH: https://github.com/sizzlelab/asi/tree/rails2

Here are the instructions to put your own installation of ASI server to a computer where you have access. During the development, we have not yet had many people hosting ASI outside the core team, so the instructions may be less thorough than preferred. However, please send us your questions if you get stuck and we’ll try to help you (and enhance the instructions on the way). Also, if you yourself find out something that is missing from the instructions or would make the documentation better, please use the edit button of this wiki page and make the additions immediately. All questions and helpful additions are appreciated.

Getting required gems etc.

First you need to install ruby, ruby-dev and rubygem on the target machine. After that you need to install imagemagick and other dependencies: update gems, install rails v2.3.2 (other versions do not work at the moment), andand and whenever via rubygems:

gem update --system
sudo gem install -v=2.3.2 rails
sudo gem install andand
sudo gem install whenever -v=0.4.1

At this point it is possible that gem will install the latest version of json_pure. Currently ASI requires version 1.2.2 of json and json pure so you will have to install version 1.2.2 of json and json_pure, and then remove the latest version(s), as this will otherwise cause errors later on.

sudo gem uninstall json_pure -v=1.4.6
sudo gem install json_pure -v=1.2.2
sudo gem install json -v=1.2.2
sudo gem install rake -v=0.8.7

You may run into problems using the latest rake (>0.9), so for this rails2 branch of ASI specify to use rake 0.8.7.

Download and install mysql, 32 bit (x86). For Mac OS X 10.6 you need to use 64 bit version. Make sure mysql is in PATH as well as make sure that mysql_config is installed on the machine. After that you need to install mysql gem and rubycas client:

sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
(For Mac OS X 10.6 use: sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config )
sudo gem install rubycas-client

ASI requires rmagick for imagemagick manipulations:

sudo gem install rmagick

If this does not work you may need to install libmagick-dev package and the libmagick++-dev package (ubuntu), and even after that if you get an error stating that you have an incomplete ImageMagick package the best thing to do is to remove it and install from source.

Install Sphinx

Depending on your environment install Sphinx from source, or from macports. See Sphinx installation instructions. (use Sphinx 0.9.9)

After Sphinx is installed install the rubygem for it:

sudo gem install thinking-sphinx

Make sure indexer is in your path.

Getting ASI code itself

Now clone ASI source from github and cd into the asi/ directory.

Configuration

You need to edit the configuration to match your system:

  1. edit details in the install.sql
    • (at least you have to replace all the “password_here” with the some password)
  2. cp config/database.example.yml config/database.yml
  3. edit details according to your database and (what you put in install.sql) to database.yml
  4. cp config/config.example.yml config/config.yml
  5. edit details according to your system configuration to config.yml

You need to prepare the database by running install.sql against it, with mysql user preferably (you have to create this separately). After that you are ready to run:

rake RAILS_ENV=production db:migrate

Please note that this only prepares the database for production environment. Should you want to prepare the development environment’s database you need to run rake db:migrate in development mode:

rake RAILS_ENV=development db:migrate

On Ubuntu you may at this point get an error stating `gem_original_require’: no such file to load — net/https. To fix this you need to install libopenssl-ruby.

Also, before starting ASI for the first time you should rebuild the thinking_sphinx indices and start the searchd daemon, as otherwise some of the API calls will run slow and you will get error messages regarding missing something.sphinx.conf file. To see all thinking_sphinx related options run:

rake -D thinking_sphinx

To rebuild the index and start daemon run:

rake thinking_sphinx:rebuild

Please note that you may have to create a startup script to start searchd automatically as your system boots up.

Starting ASI

Finally you are ready to run ASI:

script/server

The line above will by default start the server in “development” environment". So use “script/server -e production” for production environment settings.

Generating Documentation

In order to view the API documentation on localhost you have to generate the rapidocs first by running:

rake doc:app
script/rapidoc/generate 

Environment settings

You will have to edit config/environments/development.rb, config/environments/test.rb and config/environments/production.rb files to correspond to your enviroment / domain.

Allowing external services to contact ASI

ASI has a list of client applications that are allowed to use in in the database table of “clients”

You can create a new clients (application ID & password pair) in the rails console. (other models can be manipulated in a similar manner).

script/console

or (for production environment)

script/console production

Remember that by default, the databases for development and production environments of a Rails app are different so the client needs to be added separately to development and production databases, if needed in both.

There you can run Client.create to store new clients to your database

Client.create({:name => "app_name", :password=>"pswd_for_the_app", :show_email => true})

The password will be stored in encrpted format in the database so it will not be seen in clear text after this. The “show_email” means that this client application is allowed to get the emails for all the users in the ASI database. The idea is that you can allow less trusty applications to connect to your ASI without fearing them to download all the emails for spamming purposes. The value of “show_email” will default to false, so remember to put it true if that application needs to have access for mail addresses.