# Gorgon Setup Tutorial This is an example on how to setup [Gorgon](https://github.com/nulogy/Gorgon). For this tutorial, we will use a version of a Rails app from [Ruby on Rails Tutorial](https://www.railstutorial.org/) by Michael Hartl. ### Setup the sample Rails app First, let's clone and setup the sample Rails app. ```bash git clone git@github.com: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](https://www.rabbitmq.com/download.html). 2. Add Gorgon to the Gemfile: `gem 'gorgon', '0.8.1'` 3. `bundle` 4. 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. 5. 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. ```yml remote_test: &remote_test adapter: sqlite3 database: db/remote_test_<%=ENV['TEST_ENV_NUMBER']%> pool: 5 timeout: 5000 ``` 6. In the Gemfile, add :remote_test to every :test group. For example: ```ruby ... group :development, :test, :remote_test do gem 'sqlite3', '1.3.5' ... group :test, :remote_test do gem 'capybara', '1.1.2' ... ``` 7. Create config/environments/remote_test.rb file. This file can be just a copy of config/environments/test.rb ```bash cp config/environments/test.rb config/environments/remote_test.rb ``` ### Setting up SSH access In this tutorial, we are using [SSH Transport](/rsync_transport.md) 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](http://www.linuxproblem.org/art_9.html) to setup passwordless SSH access. ### Run Gorgon Listener 1. Download a listener configuration sample: ```bash wget https://raw.githubusercontent.com/nulogy/Gorgon/master/gorgon_listener.json.sample mv gorgon_listener.json.sample gorgon_listener.json ``` 2. Start listener ```bash gorgon listen ``` ### Run Gorgon Now, you are ready to run Gorgon. ```bash gorgon ``` ### Result If everything went well, this is what you should see: ![image](/gorgon-done-screenshot.png)