-
Notifications
You must be signed in to change notification settings - Fork 1
Installation
You need first to have installed several things in your system.
First, you have to have ruby v1.9.2 in your system. Then you need to install rubygems and bundler in order to track an application's code and the rubygems it needs to run. You may need root permissions to install.
Optional and recommendable, but not mandatory, is memcached, a high-performance and distributed memory object cache system. This is used to cache the results from external datasources (accessed via REST services) and, then, decrease the latency between requests and responses. Memcached is not mandatory and the application will run as well, but you will see minor errors on logs (cache faults) and the performance of the application will get worst in general.
As memcached does not persist data into disc (it is only a cache memory system), in order not to lose the cache content on host crash or shutdown, the application saves every request and result in a Mysql database just as memcached does it into memory. So, a mysql database is used as backup. This is a mandatory requirement, otherwise the application won't work correctly.
A script to import cache entries from the database into the memcached can be found at inab/tdcache-importer repository. It is recommendable this script runs on host startup after memcached server starts in order to restoring the cache as soon as possible after a crash.
Here, local is referring to databases which the application have straight access to. There are two local datasources. One of them was named before when talking on cache and it's the mysql memcached backup.
The other is used to store the IntAct protein-protein interactins database, as external REST requests to it were found too slow. So, a subset of the interaction data is stored in a Postgres database. More information and a small ruby application to import IntAct db as a MITAB25 file into a database.
As the application uses two 'local' databases (different than external remote services) and makes requests from the client side, you need to configure parameters for database connection and client side requests.
For this application, you will have to edit two configuration files, which are shipped with the applications as examples. These ones are app_settings.example.yml and application.example.rb, they have to be renamed into app_settings.yml and application.rb.
-
/config/app_settings.ymlthis is a YAML file and the there is only to things to edit,tsv_rails_hostto set the name of the host where the application is to run; andtsv_rails_portis the port where the application is listening for requests (this has to match with the value of the -p paramater inrails server -p) -
/config/application.rbdefines the databases connection parameters. Search for 'opts' and 'opts_mysql' variables in the file and replace the values with your own values. -
/config/initializers/swagger.rbconfigures swagger to display the API endpoints. The point here is change the:base_pathparameter of theadd_swagger_documentationmethod at the bottom of the file in order to set the root of the web application. See below the API deployment below for more information.
Then, you need the application code, so git-clone or download the application as a zip file from Github into a directory of your choice. Then run bundle install from the directory where the code was downloaded (the root application directory). This process will install all dependencies as listed in Gemfile file (gems). While installing the dependencies, you will get a listing of the gems installed and, if everything was fine, you will get a final message as all gems were installed successfully.
From this point, the application should be ready to be run
The API development was implemented with the help of the grape gem to create the API endpoints just from the business logic. Grape also provides methods to document each endpoint with description, paramaters and return values. In order to visualize the API documentation, swagger-UI was chosen which, along with the grape-swagger gem, makes pretty easy to display the API documentation in a convenient way and play around with the API functions.
An additional feature swagger-UI provides is that it doesn't have to be inside the web application, as it is absolutely independent on any API framework. So, if you want to make accessible the Target Dossier API using swagger-UI:
- download swagger-UI from its github repo and pay attention to the
distdirectory. In that directory you will find everything you need to start working with swagger-UI as-is. - so, just drop the files in the
distdirectory in a folder of your choice inside the web server. - in order to configure swagger-UI to display your API docs, open
index.htmland changediscoveryUrlandapiKey. The first one has to point to<web application root>/swagger_doc.json. The apiKey can be an empty string, depending on your installation. - when it's done, just type the url where swagger-UI was installed in the web server to access the API documentation and playground
Just type rails server to start the rails application, which will be reachable by typing http://localhost:3000 on the browser.