-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
46 lines (41 loc) · 1.48 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
# encoding: utf-8
#!/usr/bin/env ruby
require "bundler/gem_tasks"
namespace :redis do
desc "Create redis.conf out of redis.yml or config/redis.yml"
task :config do
mask = '{config/,}{redis,rhack}.yml'
src = '/home/shinku/redis.yml'#FileList[mask].first
unless src
puts "Source yml file is not found, searched mask: #{mask}"
exit
end
require 'active_support'
require 'rmtools'
rcfg = YAML.load(IO.read src)
if src['rhack']
rcfg = rcfg.db.redis
end
dest = rcfg.configfilename || File.expand_path('config/redis.conf')
if uptodate? dest, [src]
puts dest+' is allready up to date'
else
config = {}
config.daemonize = rcfg.daemonize || 'yes'
config.pidfile = rcfg.pidfile || File.expand_path('tmp/pids/redis.pid')
config.port = rcfg.port || 0
if rcfg.port.to_i == 0
config.unixsocket = rcfg.socket || File.expand_path('tmp/sockets/redis.sock')
config.unixsocketperm = rcfg.socketperm || 775
end
config.logfile = rcfg.logfile || File.expand_path('log/redis.log')
config.loglevel = rcfg.loglevel || 'notice'
config.dir = rcfg.dir || './'
config.dbfilename = rcfg.dbfilename || File.expand_path('db/dump.rdb')
config.databases = rcfg.databases || 1
config = config.to_a.joins(' ') + (rcfg.save || ['900 1', '300 10', '60 10000']).map {|i| "save #{i}"}
RMTools::rw dest, config*"\n"
puts "Written configuration to #{dest}"
end
end
end