Report abuse

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
set :application, "mydomain.com"

# source control
set :scm, :git
set :branch, 'master'
set :scm_verbose, true
set :repository,  "git@mydomain.com:myapp"
set :deploy_via, :copy
#set :copy_strategy, :export

# source control - attempt to use the default deployment strat
#set :repository,  "file:///home/git/repositories/myapp.git"
#set :local_repository, "git@mydomain.com:myapp"
#set :use_sudo, true
#set :scm_username, "git"

# deployment path
set :deploy_to, "/srv/www/rails/#{application}"

# servers and roles
set :domain, "mydomain.com" # just a helper for below
role :web, domain                          # Your HTTP server, Apache/etc
role :app, domain                          # This may be the same as your `Web` server
role :db,  domain, :primary => true        # This is where Rails migrations will run

default_run_options[:pty] = true

# server login credentials
set :user, "thedeeno"
set :ssh_options, { :forward_agent => true } # allow ssh to use ssh keys in agent
                                             # this doesn't appear to work as I still get
                                             # prompted for a password.

# misc
set :server_name, "mydomain.com"
set :server_alias, "*.mydomain.com"

namespace :deploy do

  task :start do
    run "/etc/init.d/apache2 start"
  end

  task :stop do
    run "/etc/init.d/apache2 stop"
  end

  task :restart, :roles => :app, :except => { :no_release => true } do
    run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
  end

  task :symlinks do
    # link database.yml
    run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
  end
end

after 'deploy:update_code', 'deploy:symlinks'