add a launchctl script for redis-server

Signed-off-by: Adam Vandenberg <flangy@gmail.com>
This commit is contained in:
Corey Donohoe 2010-05-29 13:57:40 -07:00 committed by Adam Vandenberg
parent 9423dba851
commit 8fe3bb0ef7

View file

@ -15,9 +15,7 @@ class Redis <Formula
bin.install p rescue nil
}
%w( run db/redis log ).each do |path|
(var+path).mkpath
end
%w( run db/redis log ).each { |p| (var+p).mkpath }
# Fix up default conf file to match our paths
inreplace "redis.conf" do |s|
@ -26,15 +24,45 @@ class Redis <Formula
end
etc.install "redis.conf"
(prefix+'io.redis.redis-server.plist').write startup_plist
end
def caveats
<<-EOS.undent
To start redis:
Automatically load on login with:
launchctl load -w #{prefix}/io.redis.redis-server.plist
To start redis manually:
redis-server #{etc}/redis.conf
To access the server:
redis-cli
EOS
end
def startup_plist
return <<-EOPLIST
<?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>KeepAlive</key>
<true/>
<key>Label</key>
<string>io.redis.redis-server</string>
<key>ProgramArguments</key>
<array>
<string>#{bin}/redis-server</string>
<string>#{etc}/redis.conf</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>UserName</key>
<string>#{`whoami`.chomp}</string>
<key>WorkingDirectory</key>
<string>#{var}</string>
</dict>
</plist>
EOPLIST
end
end