Class: Thin

Inherits:
Object
  • Object
show all
Defined in:
lib/brisk/thin.rb

Class Method Summary collapse

Class Method Details

.downloadObject



57
58
59
60
61
# File 'lib/brisk/thin.rb', line 57

def self.download
  system "gem install thin > /dev/null"

  $? == 0
end

.installObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/brisk/thin.rb', line 5

def self.install
   unless is_installed?


     if download
       puts "Successfuly installed thin".colorize(:green)
     else
       puts "Something went wrong while installing thin. The process gets stopped".colorize(:red)
       exit
     end
   end

   install_daemon
   install_secure_daemon
   install_site_daemon
end

.install_daemonObject



28
29
30
31
32
33
34
35
36
37
# File 'lib/brisk/thin.rb', line 28

def self.install_daemon
  path = FileSystem.get_path("../../stubs/daemon.plist", __dir__)
  server = FileSystem.get_path("server/config.ru", __dir__)

  file = FileSystem.read(path)

  new_file = file.gsub("SERVER_PATH", server)

  FileSystem.write("/Library/LaunchDaemons/com.frankleef.briskServer.plist", new_file)
end

.install_secure_daemonObject



39
40
41
42
43
44
45
46
47
# File 'lib/brisk/thin.rb', line 39

def self.install_secure_daemon
  path = FileSystem.get_path("../../stubs/secure_daemon.plist", __dir__)
  server = FileSystem.get_path("server/config.ru", __dir__)

  file = FileSystem.read(path)

  new_file = file.gsub("SERVER_PATH", server)
  FileSystem.write("/Library/LaunchDaemons/com.frankleef.briskSecureServer.plist", new_file)
end

.install_site_daemonObject



49
50
51
52
53
54
55
# File 'lib/brisk/thin.rb', line 49

def self.install_site_daemon
  path = FileSystem.get_path("../../stubs/remove_site.plist", __dir__)
  file = FileSystem.read(path)

  new_file = file.gsub("USER", ENV["HOME"])
  FileSystem.write("/Library/LaunchDaemons/com.frankleef.removeSite.plist", new_file)
end

.is_installed?Boolean

Returns:

  • (Boolean)


63
64
65
66
67
# File 'lib/brisk/thin.rb', line 63

def self.is_installed?
  system "gem list -i thin > /dev/null"

  $? == 0
end

.restartObject



69
70
71
72
73
# File 'lib/brisk/thin.rb', line 69

def self.restart
  stop

  start
end

.startObject



75
76
77
78
79
# File 'lib/brisk/thin.rb', line 75

def self.start
  system "launchctl load /Library/LaunchDaemons/com.frankleef.briskServer.plist > /dev/null"
  system "launchctl load /Library/LaunchDaemons/com.frankleef.briskSecureServer.plist > /dev/null"
  system "launchctl load /Library/LaunchDaemons/com.frankleef.removeSite.plist > /dev/null"
end

.stopObject



81
82
83
84
85
# File 'lib/brisk/thin.rb', line 81

def self.stop
  system "launchctl unload /Library/LaunchDaemons/com.frankleef.briskServer.plist > /dev/null"
  system "launchctl unload /Library/LaunchDaemons/com.frankleef.briskSecureServer.plist > /dev/null"
  system "launchctl unload /Library/LaunchDaemons/com.frankleef.removeSite.plist > /dev/null"
end

.updateObject



22
23
24
25
26
# File 'lib/brisk/thin.rb', line 22

def self.update
  system "sudo rm /Library/LaunchDaemons/com.frankleef.briskServer.plist >> /dev/null"
  system "sudo rm /Library/LaunchDaemons/com.frankleef.rubyValetServer.plist >> /dev/null"
  install
end