Configuration

wfarr edited this page Mar 11, 2011 · 4 revisions

Most of the configuration for deploying your Rails application will go into config/moonshine.yml.

Dynamic configuration

Any of the options shown below could also be configured using the configure method in your manifest. If the configuration is static, it is easier to read them in moonshine.yml. The example below configures the Passenger max pool size differently depending on the stage you are deploying to. This assumes you are using the capistrano-ext gem for multistage deployment.

  configure( :passenger => {:max_pool_size => deploy_stage == 'production' ? 12 : 2 })

Examples

System Ruby

Options are ree and mri

:ruby: ree

Basic Rails configuration.

:application: your_app_name
:user: rails
:deploy_to: /srv/your_app_name
:repository: git@github.com:username/your_app_name.git

Apache vhost

:domain: yourapp.com
:domain_aliases:
  - assets1.yourapp.com
  - assets2.yourapp.com

Apache basic auth

This allows anyone from the 192.168.1 subnet or users who can log in. Also useful are the :deny and :satisfy directives. More info from the Apache docs.

:apache:
  :users:
    :admin: sekrit
  :allow: 192.168.1

System Timezone

Timezone to use on the server. This can be set to any of the files in /usr/share/zoneinfo/ on your Ubuntu server. UTC is the default. Other options include GMT, America/New_York, and Navajo.

:time_zone: UTC

Note that Rails’ time zone support expects your database, or your server, to be configured for UTC. MySQL will use the system time zone by default, so you should leave this as the default unless you have a compelling reason to change it (e.g. you haven’t integrated time zone support in your app). Alternatively, you can explicitly configure MySQL if you wish to have it set differently from the server for some reason:

:mysql:
  :default_time_zone: foo

Public asset directories

Use :app_symlinks to setup directories under public/ that you want to persist across deployments. They’ll be symlinked to the shared directory.

:app_symlinks:
  - uploads

Non-versioned configuration files

Use :local_config to copy directories straight from your local project directory to the server: these are files that you don’t have/want in scm.

:local_config:
  - config/database.yml

Directories under the application’s shared directory.

These should probably be left as is unless you need to add more for some reason.

:shared_children:
- system
- log
- pids
- config

Gem Sources

Moonshine now includes gemcutter.org as a gem source by default, and gives it priority over rubyforge. The defaults are illustrated here — you can change or reorder them to your liking:

:rubygems:
  :sources:
    - http://gemcutter.org
    - http://gems.rubyforge.org
    - http://gems.github.com

Gem Dependencies

After specifying a gem with config.gem, run ‘rake moonshine:gems’ to update config/gems.yml. If the gem depends on native packages, tell Moonshine here. Moonshine automatically knows about dependencies for some common gems: curb,mysql,sqlite3-ruby,nokogiri,rmagick,paperclip,thoughtbot-paperclip,mini_magick,postgres

:apt_gems:
  :awesomegem:
    - awesome
    - libawesome-dev

Passenger

To see all the options for these services, look at the variables in their respective ERB templates under moonshine/lib/moonshine/manifest/rails/templates

:passenger:
  :version: 3.0.4 # Force passenger to remain at this version
  :max_pool_size: 3 # Use a maximum of 3 passenger workers
  :use_global_queue: true # Use the global request queue

Apache, MySQL, Postgres

To see all the options for these services, look at the variables in their respective ERB templates under moonshine/lib/moonshine/manifest/rails/templates

:mysql:
  :innodb_buffer_pool_size: 128M