Class: Shutup::Server

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

Class Method Summary collapse

Class Method Details

.current_dirObject



4
5
6
# File 'lib/shutup/server.rb', line 4

def current_dir
  File.expand_path(File.dirname('.'))
end

.delete_pidObject



29
30
31
# File 'lib/shutup/server.rb', line 29

def delete_pid
  File.delete(pid_file) if File.exist?(pid_file)
end

.hit!Object



21
22
23
24
25
26
27
# File 'lib/shutup/server.rb', line 21

def hit!
  if pid
    system "kill -9 #{pid}"
    puts "Killed process id: #{pid}"
    true
  end
end

.pidObject



12
13
14
15
16
17
18
19
# File 'lib/shutup/server.rb', line 12

def pid
  begin
    File.read(pid_file)
  rescue => e
    e.message << ' Are you sure that the process is running?'
    raise(e)
  end
end

.pid_fileObject



8
9
10
# File 'lib/shutup/server.rb', line 8

def pid_file
  "#{current_dir}/tmp/pids/server.pid"
end