Module: Shuttle::Support::Thin

Included in:
Rails, Ruby
Defined in:
lib/shuttle/support/thin.rb

Instance Method Summary collapse

Instance Method Details

#thin_configObject



3
4
5
# File 'lib/shuttle/support/thin.rb', line 3

def thin_config
  config.thin || Hashr.new
end

#thin_envObject



19
20
21
# File 'lib/shuttle/support/thin.rb', line 19

def thin_env
  environment
end

#thin_hostObject



7
8
9
# File 'lib/shuttle/support/thin.rb', line 7

def thin_host
  thin_config.host || "127.0.0.1"
end

#thin_optionsObject



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/shuttle/support/thin.rb', line 23

def thin_options
  [
    "-a #{thin_host}",
    "-p #{thin_port}",
    "-e #{thin_env}",
    "-s #{thin_servers}",
    "-l #{shared_path('log/thin.log')}",
    "-P #{shared_path('pids/thin.pid')}",
    "-d"
  ].join(' ')
end

#thin_portObject



11
12
13
# File 'lib/shuttle/support/thin.rb', line 11

def thin_port
  thin_config.port || "9000"
end

#thin_restartObject



51
52
53
54
55
56
57
# File 'lib/shuttle/support/thin.rb', line 51

def thin_restart
  if ssh.file_exists?(shared_path("pids/thin.#{thin_port}.pid"))
    thin_stop
  end

  thin_start
end

#thin_serversObject



15
16
17
# File 'lib/shuttle/support/thin.rb', line 15

def thin_servers
  thin_config.servers || 1
end

#thin_startObject



35
36
37
38
39
40
41
42
43
# File 'lib/shuttle/support/thin.rb', line 35

def thin_start
  log "Starting thin"

  res = ssh.run("cd #{release_path} && ./bin/thin #{thin_options} start")

  unless res.success?
    error "Unable to start thin: #{res.output}"
  end
end

#thin_stopObject



45
46
47
48
49
# File 'lib/shuttle/support/thin.rb', line 45

def thin_stop
  log "Stopping thin"

  ssh.run("cd #{release_path} && ./bin/thin #{thin_options} stop")
end