Class: Rsm::Install::Rails

Inherits:
Base
  • Object
show all
Defined in:
lib/tasks/install/rails.rb

Constant Summary

Constants inherited from Base

Base::SERVERS

Constants included from Actions

Actions::TAR_OPTS

Instance Attribute Summary collapse

Attributes inherited from Base

#server, #socket_per_worker, #worker_processes

Instance Method Summary collapse

Methods inherited from Base

#set_destination_root, #set_server, #set_worker_processes, source_root, template_path

Methods included from Actions

#application_root, #downloaded_file, #fetch_temporary_archive, #ruby_binary, #run_ruby_binary, #run_with_bundler, #unpack_compressed_archive

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



5
6
7
# File 'lib/tasks/install/rails.rb', line 5

def host
  @host
end

#portObject (readonly)

Returns the value of attribute port.



5
6
7
# File 'lib/tasks/install/rails.rb', line 5

def port
  @port
end

#socketObject (readonly)

Returns the value of attribute socket.



5
6
7
# File 'lib/tasks/install/rails.rb', line 5

def socket
  @socket
end

Instance Method Details

#define_varsObject



35
36
37
38
39
40
41
42
43
44
# File 'lib/tasks/install/rails.rb', line 35

def define_vars
  @socket = options[:socket]
  @host = options[:host]
  @port = options[:port]
  @config_dir = if options[:capistrano]
          "../shared"
        else
          "config"
        end
end

#downloadObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/tasks/install/rails.rb', line 18

def download
  empty_directory "."
  inside application_root do
    if options[:git]
      run "git clone #{options[:git]} ."
    elsif options[:tgz]
      fetch_temporary_archive(name, options[:tgz], :gz)
      unpack_compressed_archive(name, :gz)
    elsif options[:tbz2]
      fetch_temporary_archive(name, options[:tbz2], :bz2)
      unpack_compessed_archive(name, :bz2)
    else
      say "No source URI specified - skip download"
    end
  end
end

#permissionsObject



74
75
76
77
78
79
80
81
# File 'lib/tasks/install/rails.rb', line 74

def permissions
  inside "." do
    empty_directory "log"
    empty_directory "tmp"
    run "chown #{options[:user]}:#{options[:group]} -R ."
    run "chmod 755 log tmp"
  end
end

#server_configObject



70
71
72
# File 'lib/tasks/install/rails.rb', line 70

def server_config
  send("#{server}_config")
end

#thin_configObject



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/tasks/install/rails.rb', line 51

def thin_config
  env = options[:environment]
  inside "." do
    cmd = "thin config -C #@config_dir/thin.#{env}.yml -s #{options[:worker_processes]} -e #{env} -l log/thin.#{env}.log -P tmp/pids/thin.#{env}.pid"
    if socket
      cmd << " -S tmp/sockets/thin.#{env}.sock"
    else
      if host
        cmd << " -a #{host}"
      end
      if port
        cmd << " -p #{port}"
      end
    end
    run_with_bundler cmd
  end
end

#unicorn_configObject



46
47
48
# File 'lib/tasks/install/rails.rb', line 46

def unicorn_config
  template "unicorn.rb.erb", "#@config_dir/unicorn.rb"
end