forked from tombh/peas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Guardfile
77 lines (65 loc) · 1.29 KB
/
Guardfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
require 'guard/plugin'
guard 'bundler' do
watch('Gemfile')
end
group :server do
guard 'puma', port: ENV['PORT'] || '4000', bind: 'tcp://0.0.0.0', quiet: false do
watch('Gemfile.lock')
watch(%r{^(config|lib|api)/.*})
end
end
module ::Guard
class BaseGuard < ::Guard::Plugin
def log msg
puts "GUARD: #{msg}"
end
def service_name
self.class.name
end
def start
log "Starting #{service_name}"
# TODO check if already running
@pid = spawn command
log "#{service_name} running with PID #{@pid}"
@pid
end
def stop
if @pid
log "Sending KILL signal to #{service_name} PID #{@pid}"
Process.kill("KILL", @pid)
true
end
end
def reload
stop
start
end
def run_all
true
end
def run_on_changes(paths)
reload
end
end
end
module ::Guard
class SwitchboardServer < BaseGuard
def command
'bundle exec ./bin/switchboard'
end
end
end
guard 'switchboard_server' do
watch(%r{switchboard/server/.*})
end
module ::Guard
class SwitchboardClients < BaseGuard
def command
'bundle exec ./bin/gardener'
end
end
end
guard 'switchboard_clients' do
watch(%r{switchboard/clients/.*})
watch(%r{^(lib/worker|api/models)/.*})
end