forked from maddox/wallop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
68 lines (57 loc) · 1.62 KB
/
Rakefile
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
def plist_path
File.expand_path("~/Library/LaunchAgents/com.wallop.plist")
end
def log_path
File.expand_path("~/Library/Logs/wallop.log")
end
namespace :wallop do
desc "Uninstall Wallop from launching on boot"
task :uninstall do
puts "Removing Wallop from launchd"
if File.exist?(plist_path)
`launchctl unload -w #{plist_path}`
end
end
desc "Install Wallop to launch on boot"
task :install do
puts "Setting up Wallop in launchd"
plist = %{
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>EnvironmentVariables</key>
<dict>
<key>RACK_ENV</key>
<string>production</string>
</dict>
<key>Label</key>
<string>com.wallop.plist</string>
<key>ProgramArguments</key>
<array>
<string>script/start</string>
</array>
<key>OnDemand</key>
<false/>
<key>AbandonProcessGroup</key>
<false/>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>WorkingDirectory</key>
<string>#{File.join(File.dirname(__FILE__))}</string>
<key>StandardErrorPath</key>
<string>#{log_path}</string>
<key>StandardOutPath</key>
<string>#{log_path}</string>
</dict>
</plist>
}
`touch #{log_path}`
File.open(plist_path, 'w+') do |f|
f.puts plist
end
`launchctl load -w #{plist_path}`
end
end