Skip to content

Commit

Permalink
improved documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
allangrant committed Oct 8, 2010
1 parent 9ae2b55 commit 4bbfd8e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 18 deletions.
35 changes: 21 additions & 14 deletions README.txt
Expand Up @@ -30,24 +30,28 @@ For the Capistrano deployment to work without modifications, you need to:

SETUP:
1. Edit master.rb and set constants at the top
2. Upload contents of server-templates into server templates directory on server
3. Setup god
4. Upload nginx scripts or write your own.
5. Use it!
2. Copy mailer.yml.example to mailer.yml and update with your SMTP information
3. Upload contents of server-templates into some directory on your server. Put the path to that dir into SERVER_TEMPLATES_PATH in master.rb.
4. Setup god
5. Upload nginx scripts or write your own.
6. Use it!

Detailed below:

1. Edit master.rb and set the constants at the top to values appropriate for your system:
ERROR_EMAIL = "pheonix@gmail.com" # Address that exception_notifier should send error reports to
ERROR_EMAIL = "allan.grant@gmail.com" # Address that exception_notifier should send error reports to
SYSTEM_SENDER_EMAIL = "allan.grant.dev@gmail.com" # Address that exception_notifier will send from
SERVER_TEMPLATES_PATH = "/home/rails/templates" # Path to .erb templates on server, from /server-templates
SERVER_DEPLOY_PATH = "/home/rails" # Path to where all rails applications are deployed on server
SERVER_NGINX_APPS_PATH = "/etc/nginx/sites-available" # Path to nginx sites-available directory
GOD_PATH = "/opt/ruby/bin/god" # Path to god. Search for the truth. Enlightenment. 42
GIT_SERVER = "git@allangrant.in" # Git server, for git and scp.
GIT_ORIGIN = "#{GIT_SERVER}:#{APPLICATION}.git" # Git origin, in scp format. user@server:path
GIT_ABS_PATH = "/home/git/\#{application}.git" # Where git repository should be created
USE_PLUGIN_SUBMODULES = true # Set to true to submodule plugins for easy updating, or false to freeze plugins at current version.
SERVER_USER = "rails" # Name of the user hosting rails on server
DEFAULT_DOMAIN = "#{APPLICATION}.com" # Default domain of the app, and server where capistrano will connect.

USE_PLUGIN_SUBMODULES = true # Set to true to submodule plugins for easy updating, or false to freeze plugins at current version.
CACHED_PLUGINS_PATH = "/var/rails_plugins" # READ BELOW: (only needed when USE_PLUGIN_SUBMODULES is true)
Using cached_plugin, you rewrite your plugin include paths to point to local clones of their git repositories.
Why? To speed up creating new rails projects or deploying via capistrano. Since plugins are included as submodules,
Expand All @@ -64,17 +68,21 @@ Or rewrite the link to this (if CACHED_PLUGINS_PATH is '~/rails_plugins' here):
NOTE: If you use cached plugin paths, they have to be the same on your dev & production servers for capistrano deploys to work.
It's a bit of a dirty hack, but works for me. Anyone have a better solution?

2. Upload contents of server-templates into server templates directory on server
2. Copy mailer.yml.example to mailer.yml and update with your SMTP information
Copy mailer.yml.example to mailer.yml and update with your development SMTP information.
Note: There is a mailer.yml.example file in the root directory of this repository and a mailer.yml in the server-templates directory. The file in the root is for the development server (when you first generate a project from the template) and the file in the server-templates directory is for the production server.

3. Upload contents of server-templates into some directory on your server. Put the path to that dir into SERVER_TEMPLATES_PATH in master.rb.
The capistrano deploy script uses templates to create database.yml, mailer.yml, and nginx site config files on the server, so the settings can be different from server to server if necessary. Place the contents on your server, and put the path into the
SERVER_TEMPLATES_PATH constant in master.rb. Edit the templates to fit your server configuration.

3. Setup god
4. Setup god
Install god (http://god.rubyforge.org/) and create an init.d script. One is provided in god-config directory of this project.
Set it to start automatically as root: update-rc.d god defaults 85 15
Create /etc/god.conf on your server, with contents similar to the god.conf file in god-config.
Make the the path in god.conf matches your rails application path.

4. Upload nginx scripts or write your own.
5. Upload nginx scripts or write your own.
Inside nginx_scripts you'll find nxenable, nxdisable, nxrestart, and README.txt. The scripts enable or disable nginx sites,
and restart the server. This is encapsulated in scripts, so that sudo permission can be granted to those scripts if password-less
deploy is desired. Here is what my sudoers file contains:
Expand All @@ -83,14 +91,13 @@ rails ALL=NOPASSWD:/opt/ruby/bin/rake,/usr/bin/rake,/usr/local/bin/nxenable,/u
Please these scripts somewhere in your path so they'll run.
Alternatively you could write your own versions, or change config/deploy.rb to enable/disable sites some other way.

5. Use it!

6. Use it!
Create a new project:
rails -m ~/templates/master.rb -d mysql weblog

Deploy it (note: it'll expect to be deployed at weblog.com. If your server is something else, edit config/deploy.rb and put it on the second line):
cap git:setup
cap deploy:update
Deploy it:
cap deploy:setup
Note: It'll expect to be deployed at "#{APPLICATION}.com", which in this example would be weblog.com. To change, edit DEFAULT_DOMAIN in master.rb in the template or config/deploy.rb in the app.

Now let's add posts:
./script/generate haml_scaffold posts title:string author:string body:text
Expand Down
2 changes: 1 addition & 1 deletion authlogic.rb
Expand Up @@ -295,7 +295,7 @@ def self.down

file 'app/models/notifier.rb', <<-CODE
class Notifier < ActionMailer::Base
SYSTEM_ACCOUNT = %("#{APPLICATION.titlecase}" <pheonix8d@gmail.com>)
SYSTEM_ACCOUNT = %("#{APPLICATION.titlecase}" <#{SYSTEM_SENDER_EMAIL}>)
def welcome(user)
subject 'Welcome to #{APPLICATION.titlecase}'
Expand Down
1 change: 1 addition & 0 deletions capistrano.rb
Expand Up @@ -3,6 +3,7 @@
capify!

file 'config/deploy.rb', <<-CODE
require 'fileutils'
set :application, "#{APPLICATION}"
set :domain, "#{SERVER_DOMAIN}"
Expand Down
2 changes: 1 addition & 1 deletion exception_notifier.rb
Expand Up @@ -9,6 +9,6 @@ class ApplicationController < ActionController::Base
end
ExceptionNotifier.exception_recipients = %w(#{ERROR_EMAIL})
ExceptionNotifier.sender_address = %("#{APPLICATION.upcase} Error" <#{ERROR_EMAIL}>)
ExceptionNotifier.sender_address = %("#{APPLICATION.upcase} Error" <#{SYSTEM_SENDER_EMAIL}>)
ExceptionNotifier.email_prefix = '[#{APPLICATION.upcase}] '
CODE
5 changes: 3 additions & 2 deletions master.rb
@@ -1,7 +1,8 @@
APPLICATION = File.split(root).last # The application name is whatever was provided after "rails" command
TEMPLATE_PATH = File.split(template).first

ERROR_EMAIL = "pheonix@gmail.com" # Address that exception_notifier should send error reports to
ERROR_EMAIL = "allan.grant@gmail.com" # Address that exception_notifier should send error reports to
SYSTEM_SENDER_EMAIL = "allan.grant.dev@gmail.com" # Address that e-mails will send from
SERVER_TEMPLATES_PATH = "/home/rails/templates" # Path to .erb templates on server, from /server-templates
SERVER_DEPLOY_PATH = "/home/rails" # Path to where all rails applications are deployed on server
SERVER_NGINX_APPS_PATH = "/etc/nginx/sites-available" # Path to nginx sites-available directory
Expand All @@ -11,8 +12,8 @@
GIT_ABS_PATH = "/home/git/\#{application}.git" # Where git repository should be created
SERVER_USER = "rails" # Name of the user hosting rails on server
DEFAULT_DOMAIN = "#{APPLICATION}.com" # Default domain of the app, and server where capistrano will connect.
USE_PLUGIN_SUBMODULES = true # Set to true to submodule plugins for easy updating, or false to freeze plugins at current version.

USE_PLUGIN_SUBMODULES = true # Set to true to submodule plugins for easy updating, or false to freeze plugins at current version.
CACHED_PLUGINS_PATH = "/var/rails_plugins" # READ BELOW: (only needed when USE_PLUGIN_SUBMODULES is true)
# Using cached_plugin, you rewrite your plugin include paths to point to local clones of their git repositories.
# Why? To speed up creating new rails projects or deploying via capistrano. Since plugins are included as submodules,
Expand Down

0 comments on commit 4bbfd8e

Please sign in to comment.