Skip to content
This repository has been archived by the owner on Aug 9, 2020. It is now read-only.

Latest commit

 

History

History
97 lines (63 loc) · 2.91 KB

tutorial.md

File metadata and controls

97 lines (63 loc) · 2.91 KB

Gorgon Setup Tutorial

This is an example on how to setup Gorgon. For this tutorial, we will use a version of a Rails app from Ruby on Rails Tutorial by Michael Hartl.

Setup the sample Rails app

First, let's clone and setup the sample Rails app.

git clone [email protected]:arturopie/sample_app-1.git
cd sample_app-1/
bundle
rake db:setup
rake db:test:prepare

Run rspec and make sure all tests pass.

Setup Gorgon

  1. Install RabbitMQ.

NOTE: There is a problem with using the latest version of RabbitMQ. For now, you will need to install version 3.3.4. You can do so through this link

  1. Add Gorgon to the Gemfile: gem 'gorgon', '0.8.4'

  2. bundle

  3. Run gorgon init rails to create initial files for a typical Rails project. Gorgon will ask you to enter the AMQP host name and the File Server host name. Just press enter to use the default host (localhost).

Gorgon does not use Rails environment 'test' to run tests. Instead, one of the callbacks generated by gorgon init rails will set Rails environment to 'remote_test' before running any test. We need to setup this new environment in our Rails app.

  1. Add the following lines to config/database.yml. The callbacks will set TEST_ENV_NUMBER to its process id so that no two Gorgon runners use the same database.
remote_test: &remote_test
  adapter: sqlite3
  database: db/remote_test_<%=ENV['TEST_ENV_NUMBER']%>
  pool: 5
  timeout: 5000
  1. In the Gemfile, add :remote_test to every :test group. For example:
...
group :development, :test, :remote_test do
  gem 'sqlite3', '1.3.5'
...
group :test, :remote_test do
  gem 'capybara', '1.1.2'
...
  1. Create config/environments/remote_test.rb file. This file can be just a copy of config/environments/test.rb
cp config/environments/test.rb config/environments/remote_test.rb

Setting up SSH access

In this tutorial, we are using SSH Transport to move source code files. This requires you to have SSH access without password to File Server (in this case, to localhost). To check if you have SSH access without password, running ssh localhost should not ask for a password. If it asks for a password, follow these steps to setup passwordless SSH access.

Run Gorgon Listener

  1. Download a listener configuration sample:
wget https://raw.githubusercontent.com/nulogy/Gorgon/master/gorgon_listener.json.sample
mv gorgon_listener.json.sample gorgon_listener.json
  1. Start listener
gorgon listen

Run Gorgon

Now, you are ready to run Gorgon.

gorgon

Result

If everything went well, this is what you should see:

image