Skip to content
This repository
Browse code

Add default configuration for Redis

Signed-off-by: Max Howell <max@methylblue.com>

indirect beat defunkt to the redis formula slightly, but defunkt improved it, so everyone gets credit :)
  • Loading branch information...
commit b65435b3e8addf9eb0624a6c3f1345bbf17811df 1 parent 08dbf10
Chris Wanstrath authored September 11, 2009 mxcl committed September 11, 2009

Showing 1 changed file with 143 additions and 4 deletions. Show diff stats Hide diff stats

  1. 147  Library/Formula/redis.rb
147  Library/Formula/redis.rb
... ...
@@ -1,5 +1,140 @@
1 1
 require 'brewkit'
2 2
 
  3
+REDIS_CONF=<<-EOS
  4
+# Redis configuration file example
  5
+
  6
+# By default Redis does not run as a daemon. Use 'yes' if you need it.
  7
+# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
  8
+daemonize no
  9
+
  10
+# When run as a daemon, Redis write a pid file in /var/run/redis.pid by default.
  11
+# You can specify a custom pid file location here.
  12
+pidfile /var/run/redis.pid
  13
+
  14
+# Accept connections on the specified port, default is 6379
  15
+port 6379
  16
+
  17
+# If you want you can bind a single interface, if the bind option is not
  18
+# specified all the interfaces will listen for connections.
  19
+#
  20
+# bind 127.0.0.1
  21
+
  22
+# Close the connection after a client is idle for N seconds (0 to disable)
  23
+timeout 300
  24
+
  25
+# Save the DB on disk:
  26
+#
  27
+#   save <seconds> <changes>
  28
+#
  29
+#   Will save the DB if both the given number of seconds and the given
  30
+#   number of write operations against the DB occurred.
  31
+#
  32
+#   In the example below the behaviour will be to save:
  33
+#   after 900 sec (15 min) if at least 1 key changed
  34
+#   after 300 sec (5 min) if at least 10 keys changed
  35
+#   after 60 sec if at least 10000 keys changed
  36
+save 900 1
  37
+save 300 10
  38
+save 60 10000
  39
+
  40
+# The filename where to dump the DB
  41
+dbfilename dump.rdb
  42
+
  43
+# For default save/load DB in/from the working directory
  44
+# Note that you must specify a directory not a file name.
  45
+dir /var/db/redis/
  46
+
  47
+# Set server verbosity to 'debug'
  48
+# it can be one of:
  49
+# debug (a lot of information, useful for development/testing)
  50
+# notice (moderately verbose, what you want in production probably)
  51
+# warning (only very important / critical messages are logged)
  52
+loglevel notice
  53
+
  54
+# Specify the log file name. Also 'stdout' can be used to force
  55
+# the demon to log on the standard output. Note that if you use standard
  56
+# output for logging but daemonize, logs will be sent to /dev/null
  57
+logfile /var/log/redis.log
  58
+
  59
+# Set the number of databases. The default database is DB 0, you can select
  60
+# a different one on a per-connection basis using SELECT <dbid> where
  61
+# dbid is a number between 0 and 'databases'-1
  62
+databases 16
  63
+
  64
+################################# REPLICATION #################################
  65
+
  66
+# Master-Slave replication. Use slaveof to make a Redis instance a copy of
  67
+# another Redis server. Note that the configuration is local to the slave
  68
+# so for example it is possible to configure the slave to save the DB with a
  69
+# different interval, or to listen to another port, and so on.
  70
+
  71
+# slaveof <masterip> <masterport>
  72
+
  73
+################################## SECURITY ###################################
  74
+
  75
+# Require clients to issue AUTH <PASSWORD> before processing any other
  76
+# commands.  This might be useful in environments in which you do not trust
  77
+# others with access to the host running redis-server.
  78
+#
  79
+# This should stay commented out for backward compatibility and because most
  80
+# people do not need auth (e.g. they run their own servers).
  81
+
  82
+# requirepass foobared
  83
+
  84
+################################### LIMITS ####################################
  85
+
  86
+# Set the max number of connected clients at the same time. By default there
  87
+# is no limit, and it's up to the number of file descriptors the Redis process
  88
+# is able to open. The special value '0' means no limts.
  89
+# Once the limit is reached Redis will close all the new connections sending
  90
+# an error 'max number of clients reached'.
  91
+
  92
+# maxclients 128
  93
+
  94
+# Don't use more memory than the specified amount of bytes.
  95
+# When the memory limit is reached Redis will try to remove keys with an
  96
+# EXPIRE set. It will try to start freeing keys that are going to expire
  97
+# in little time and preserve keys with a longer time to live.
  98
+# Redis will also try to remove objects from free lists if possible.
  99
+#
  100
+# If all this fails, Redis will start to reply with errors to commands
  101
+# that will use more memory, like SET, LPUSH, and so on, and will continue
  102
+# to reply to most read-only commands like GET.
  103
+#
  104
+# WARNING: maxmemory can be a good idea mainly if you want to use Redis as a
  105
+# 'state' server or cache, not as a real DB. When Redis is used as a real
  106
+# database the memory usage will grow over the weeks, it will be obvious if
  107
+# it is going to use too much memory in the long run, and you'll have the time
  108
+# to upgrade. With maxmemory after the limit is reached you'll start to get
  109
+# errors for write operations, and this may even lead to DB inconsistency.
  110
+
  111
+# maxmemory <bytes>
  112
+
  113
+############################### ADVANCED CONFIG ###############################
  114
+
  115
+# Glue small output buffers together in order to send small replies in a
  116
+# single TCP packet. Uses a bit more CPU but most of the times it is a win
  117
+# in terms of number of queries per second. Use 'yes' if unsure.
  118
+glueoutputbuf yes
  119
+
  120
+# Use object sharing. Can save a lot of memory if you have many common
  121
+# string in your dataset, but performs lookups against the shared objects
  122
+# pool so it uses more CPU and can be a bit slower. Usually it's a good
  123
+# idea.
  124
+#
  125
+# When object sharing is enabled (shareobjects yes) you can use
  126
+# shareobjectspoolsize to control the size of the pool used in order to try
  127
+# object sharing. A bigger pool size will lead to better sharing capabilities.
  128
+# In general you want this value to be at least the double of the number of
  129
+# very common strings you have in your dataset.
  130
+#
  131
+# WARNING: object sharing is experimental, don't enable this feature
  132
+# in production before of Redis 1.0-stable. Still please try this feature in
  133
+# your development environment so that we can test it better.
  134
+shareobjects no
  135
+shareobjectspoolsize 1024
  136
+EOS
  137
+
3 138
 class Redis <Formula
4 139
   @url='http://redis.googlecode.com/files/redis-1.0.tar.gz'
5 140
   @homepage='http://code.google.com/p/redis/'
@@ -8,10 +143,14 @@ class Redis <Formula
8 143
   def install
9 144
     system "make"
10 145
 
11  
-    system "mkdir -p #{prefix}/share/redis"
12  
-    system "cp -r utils client-libraries doc #{prefix}/share/redis"
  146
+    (share+'redis').install %w( utils client-libraries doc )
  147
+    bin.install %w( redis-benchmark redis-cli redis-server )
  148
+
  149
+     # set up the conf file
  150
+    (etc+'redis.conf').write REDIS_CONF
  151
+  end
13 152
 
14  
-    system "mkdir -p #{prefix}/bin"
15  
-    system "cp redis-cli redis-benchmark redis-server #{prefix}/bin"
  153
+  def caveats
  154
+    "To start redis: $ redis-server #{etc}/redis.conf"
16 155
   end
17 156
 end

0 notes on commit b65435b

Please sign in to comment.
Something went wrong with that request. Please try again.