aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula/redis.rb
diff options
context:
space:
mode:
authorCorey Donohoe2010-05-29 13:57:40 -0700
committerAdam Vandenberg2010-05-29 18:07:16 -0700
commit7812377a2df7320f72343e88e381d7bd6859aaa9 (patch)
treef532ef7e4396a21455df58a5089e18d5e1a09314 /Library/Formula/redis.rb
parent370f9c9e28d4093328b4695f92513b0f0d23be49 (diff)
downloadhomebrew-7812377a2df7320f72343e88e381d7bd6859aaa9.tar.bz2
add a launchctl script for redis-server
Signed-off-by: Adam Vandenberg <flangy@gmail.com>
Diffstat (limited to 'Library/Formula/redis.rb')
-rw-r--r--Library/Formula/redis.rb38
1 files changed, 33 insertions, 5 deletions
diff --git a/Library/Formula/redis.rb b/Library/Formula/redis.rb
index 1fd65084b..dca2364fa 100644
--- a/Library/Formula/redis.rb
+++ b/Library/Formula/redis.rb
@@ -15,26 +15,54 @@ 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|
s.gsub! "/var/run/redis.pid", "#{var}/run/redis.pid"
s.gsub! "dir ./", "dir #{var}/db/redis/"
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