Class: Server

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

Class Method Summary collapse

Class Method Details

.is_running(path) ⇒ Object



6
7
8
# File 'lib/brisk/server/server.rb', line 6

def self.is_running(path)
  FileSystem.file_exists?("#{path}/pid.txt")
end

.is_started(path, port) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/brisk/server/server.rb', line 30

def self.is_started(path, port)
  sleep(0.5)

  pid = Pid.get(port)

  unless pid.nil?
    if Pid.alive?(pid)
      return true
    end
  end

  is_started(path, port)
end

.kill(path) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/brisk/server/server.rb', line 10

def self.kill(path)
  http = Pid.get("3001")
  https = Pid.get("3003")
  unless http.nil?
    shutdown http
  end

  unless https.nil?
    shutdown https
  end
end

.shutdown(pid) ⇒ Object



44
45
46
# File 'lib/brisk/server/server.rb', line 44

def self.shutdown(pid)
  system "sudo kill -9 #{pid}"
end

.start(path) ⇒ Object



22
23
24
# File 'lib/brisk/server/server.rb', line 22

def self.start(path)
  spawn "cd #{path} && /usr/local/bin/rerun \"/usr/local/bin/thin -d -R config.ru -a localhost -p 3001 start\""
end

.start_https(path) ⇒ Object



26
27
28
# File 'lib/brisk/server/server.rb', line 26

def self.start_https(path)
  spawn "cd #{path} && /usr/local/bin/thin start -d -R config.ru -a localhost -p 3003 --ssl"
end