Class: Thin

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

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.thin_daemonObject

Returns the value of attribute thin_daemon.



9
10
11
# File 'lib/brisk/thin.rb', line 9

def thin_daemon
  @thin_daemon
end

.thin_secure_daemonObject

Returns the value of attribute thin_secure_daemon.



10
11
12
# File 'lib/brisk/thin.rb', line 10

def thin_secure_daemon
  @thin_secure_daemon
end

Class Method Details

.downloadObject



65
66
67
68
69
# File 'lib/brisk/thin.rb', line 65

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

  $? == 0
end

.installObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/brisk/thin.rb', line 13

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



36
37
38
39
40
41
42
43
44
45
# File 'lib/brisk/thin.rb', line 36

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(thin_daemon, new_file)
end

.install_secure_daemonObject



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

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(thin_secure_daemon, new_file)
end

.install_site_daemonObject



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

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)


71
72
73
74
75
# File 'lib/brisk/thin.rb', line 71

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

  $? == 0
end

.restartObject



77
78
79
80
81
# File 'lib/brisk/thin.rb', line 77

def self.restart
  stop

  start
end

.startObject



83
84
85
86
87
# File 'lib/brisk/thin.rb', line 83

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



89
90
91
92
93
# File 'lib/brisk/thin.rb', line 89

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



30
31
32
33
34
# File 'lib/brisk/thin.rb', line 30

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