├── .dockerignore ├── .gitignore ├── Dockerfile ├── LICENSE ├── Makefile ├── README.md ├── ngx_openresty-1.7.4.1.tar.gz ├── redis.conf └── supervisor ├── conf.d ├── arping.conf ├── cron.conf └── redis.conf └── supervisord.conf /.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .*.swp 2 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM quay.io/3scale/base:trusty 2 | 3 | MAINTAINER Michal Cichra # 2014-05-21 4 | 5 | # all the apt-gets in one command & delete the cache after installing 6 | RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 136221EE520DDFAF0A905689B9316A7BC7917B12 \ 7 | && echo 'deb http://ppa.launchpad.net/chris-lea/redis-server/ubuntu trusty main' > /etc/apt/sources.list.d/redis.list \ 8 | && apt-install redis-server=2:2.8.17-1chl1~trusty1 cron supervisor logrotate \ 9 | make build-essential libpcre3-dev libssl-dev wget \ 10 | iputils-arping libexpat1-dev unzip curl 11 | 12 | ENV OPENRESTY_VERSION 1.7.4.1 13 | ADD ngx_openresty-${OPENRESTY_VERSION}.tar.gz /root/ 14 | RUN cd /root/ngx_openresty-* \ 15 | && curl https://gist.githubusercontent.com/mikz/4dae10a0ef94de7c8139/raw/33d6d5f9baf68fc5a0748b072b4d94951e463eae/system-ssl.patch | patch -p0 \ 16 | && ./configure --prefix=/opt/openresty --with-http_gunzip_module --with-luajit \ 17 | --with-luajit-xcflags=-DLUAJIT_ENABLE_LUA52COMPAT \ 18 | --http-client-body-temp-path=/var/nginx/client_body_temp \ 19 | --http-proxy-temp-path=/var/nginx/proxy_temp \ 20 | --http-log-path=/var/nginx/access.log \ 21 | --error-log-path=/var/nginx/error.log \ 22 | --pid-path=/var/nginx/nginx.pid \ 23 | --lock-path=/var/nginx/nginx.lock \ 24 | --with-http_stub_status_module \ 25 | --with-http_ssl_module \ 26 | --with-http_realip_module \ 27 | --without-http_fastcgi_module \ 28 | --without-http_uwsgi_module \ 29 | --without-http_scgi_module \ 30 | --with-md5-asm \ 31 | --with-sha1-asm \ 32 | --with-file-aio \ 33 | && make \ 34 | && make install \ 35 | && rm -rf /root/ngx_openresty* \ 36 | && ln -sf /opt/openresty/nginx/sbin/nginx /usr/local/bin/nginx \ 37 | && ln -sf /usr/local/bin/nginx /usr/local/bin/openresty \ 38 | && ln -sf /opt/openresty/bin/resty /usr/local/bin/resty 39 | 40 | RUN ln -sf /opt/openresty/luajit/bin/luajit-2.1.0-alpha /opt/openresty/luajit/bin/lua \ 41 | && ln -sf /opt/openresty/luajit/bin/lua /usr/local/bin/lua 42 | 43 | RUN wget -qO- http://luarocks.org/releases/luarocks-2.2.0.tar.gz | tar xvz -C /tmp/ \ 44 | && cd /tmp/luarocks-* \ 45 | && ./configure --with-lua=/opt/openresty/luajit \ 46 | --with-lua-include=/opt/openresty/luajit/include/luajit-2.1 \ 47 | --with-lua-lib=/opt/openresty/lualib \ 48 | && make && make install \ 49 | && rm -rf /tmp/luarocks-* 50 | 51 | #ADD redis.conf /etc/redis/ 52 | ADD supervisor /etc/supervisor 53 | ADD redis.conf /etc/redis/ 54 | 55 | ONBUILD CMD ["supervisord", "-n"] 56 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 3scale 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | TAG=$(shell git rev-parse --abbrev-ref HEAD) 2 | IMAGE=3scale/openresty:$(TAG) 3 | REPOSITORY=quay.io/$(IMAGE) 4 | 5 | build: 6 | docker build -t $(REPOSITORY) . 7 | 8 | test: 9 | docker run $(REPOSITORY) openresty -V 10 | docker run $(REPOSITORY) redis-server /etc/redis/redis.conf --daemonize yes 11 | 12 | 13 | bash: 14 | docker run -t -i $(REPOSITORY) bash 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | docker-openresty 2 | ================ 3 | 4 | Docker Image with Openresty, redis and luarocks 5 | 6 | 7 | ## Example Usage 8 | 9 | FROM 3scale/openresty 10 | 11 | ## add your supervisor openresty config 12 | ADD openresty.conf /etc/supervisor/conf.d/ 13 | 14 | # Add your app 15 | ADD . /var/www 16 | 17 | CMD ["supervisord"] 18 | 19 | ### Supervisor config 20 | Depends on your application, but something like following should work: 21 | 22 | [program:openresty] 23 | command=/opt/openresty/nginx/sbin/nginx -p /var/www/ -c config/nginx.conf -g 'daemon off;' 24 | autorestart=true 25 | 26 | 27 | ### Nginx config 28 | Supervisor expects the process not to daemonize. So make sure your nginx config has 'daemon off;'. 29 | 30 | ## Cron 31 | Cron is available and running by supervisor, so you can freely use logrotate and other cron goodies. 32 | -------------------------------------------------------------------------------- /ngx_openresty-1.7.4.1.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/3scale/docker-openresty/f9337354f47b84ddb56dd1f472ad48ed75a9f3d7/ngx_openresty-1.7.4.1.tar.gz -------------------------------------------------------------------------------- /redis.conf: -------------------------------------------------------------------------------- 1 | # Redis configuration file example 2 | 3 | # Note on units: when memory size is needed, it is possible to specify 4 | # it in the usual form of 1k 5GB 4M and so forth: 5 | # 6 | # 1k => 1000 bytes 7 | # 1kb => 1024 bytes 8 | # 1m => 1000000 bytes 9 | # 1mb => 1024*1024 bytes 10 | # 1g => 1000000000 bytes 11 | # 1gb => 1024*1024*1024 bytes 12 | # 13 | # units are case insensitive so 1GB 1Gb 1gB are all the same. 14 | 15 | ################################## INCLUDES ################################### 16 | 17 | # Include one or more other config files here. This is useful if you 18 | # have a standard template that goes to all Redis servers but also need 19 | # to customize a few per-server settings. Include files can include 20 | # other files, so use this wisely. 21 | # 22 | # Notice option "include" won't be rewritten by command "CONFIG REWRITE" 23 | # from admin or Redis Sentinel. Since Redis always uses the last processed 24 | # line as value of a configuration directive, you'd better put includes 25 | # at the beginning of this file to avoid overwriting config change at runtime. 26 | # 27 | # If instead you are interested in using includes to override configuration 28 | # options, it is better to use include as the last line. 29 | # 30 | # include /path/to/local.conf 31 | # include /path/to/other.conf 32 | 33 | ################################ GENERAL ##################################### 34 | 35 | # By default Redis does not run as a daemon. Use 'yes' if you need it. 36 | # Note that Redis will write a pid file in /var/run/redis.pid when daemonized. 37 | daemonize no 38 | 39 | # When running daemonized, Redis writes a pid file in /var/run/redis.pid by 40 | # default. You can specify a custom pid file location here. 41 | pidfile /var/run/redis.pid 42 | 43 | # Accept connections on the specified port, default is 6379. 44 | # If port 0 is specified Redis will not listen on a TCP socket. 45 | port 6379 46 | 47 | # TCP listen() backlog. 48 | # 49 | # In high requests-per-second environments you need an high backlog in order 50 | # to avoid slow clients connections issues. Note that the Linux kernel 51 | # will silently truncate it to the value of /proc/sys/net/core/somaxconn so 52 | # make sure to raise both the value of somaxconn and tcp_max_syn_backlog 53 | # in order to get the desired effect. 54 | tcp-backlog 511 55 | 56 | # By default Redis listens for connections from all the network interfaces 57 | # available on the server. It is possible to listen to just one or multiple 58 | # interfaces using the "bind" configuration directive, followed by one or 59 | # more IP addresses. 60 | # 61 | # Examples: 62 | # 63 | # bind 192.168.1.100 10.0.0.1 64 | # bind 127.0.0.1 65 | 66 | # Specify the path for the Unix socket that will be used to listen for 67 | # incoming connections. There is no default, so Redis will not listen 68 | # on a unix socket when not specified. 69 | # 70 | # unixsocket /tmp/redis.sock 71 | # unixsocketperm 700 72 | 73 | # Close the connection after a client is idle for N seconds (0 to disable) 74 | timeout 60 75 | 76 | # TCP keepalive. 77 | # 78 | # If non-zero, use SO_KEEPALIVE to send TCP ACKs to clients in absence 79 | # of communication. This is useful for two reasons: 80 | # 81 | # 1) Detect dead peers. 82 | # 2) Take the connection alive from the point of view of network 83 | # equipment in the middle. 84 | # 85 | # On Linux, the specified value (in seconds) is the period used to send ACKs. 86 | # Note that to close the connection the double of the time is needed. 87 | # On other kernels the period depends on the kernel configuration. 88 | # 89 | # A reasonable value for this option is 60 seconds. 90 | tcp-keepalive 0 91 | 92 | # Specify the server verbosity level. 93 | # This can be one of: 94 | # debug (a lot of information, useful for development/testing) 95 | # verbose (many rarely useful info, but not a mess like the debug level) 96 | # notice (moderately verbose, what you want in production probably) 97 | # warning (only very important / critical messages are logged) 98 | loglevel notice 99 | 100 | # Specify the log file name. Also the empty string can be used to force 101 | # Redis to log on the standard output. Note that if you use standard 102 | # output for logging but daemonize, logs will be sent to /dev/null 103 | logfile "" 104 | 105 | # To enable logging to the system logger, just set 'syslog-enabled' to yes, 106 | # and optionally update the other syslog parameters to suit your needs. 107 | # syslog-enabled no 108 | 109 | # Specify the syslog identity. 110 | # syslog-ident redis 111 | 112 | # Specify the syslog facility. Must be USER or between LOCAL0-LOCAL7. 113 | # syslog-facility local0 114 | 115 | # Set the number of databases. The default database is DB 0, you can select 116 | # a different one on a per-connection basis using SELECT where 117 | # dbid is a number between 0 and 'databases'-1 118 | databases 1 119 | 120 | ################################ SNAPSHOTTING ################################ 121 | # 122 | # Save the DB on disk: 123 | # 124 | # save 125 | # 126 | # Will save the DB if both the given number of seconds and the given 127 | # number of write operations against the DB occurred. 128 | # 129 | # In the example below the behaviour will be to save: 130 | # after 900 sec (15 min) if at least 1 key changed 131 | # after 300 sec (5 min) if at least 10 keys changed 132 | # after 60 sec if at least 10000 keys changed 133 | # 134 | # Note: you can disable saving completely by commenting out all "save" lines. 135 | # 136 | # It is also possible to remove all the previously configured save 137 | # points by adding a save directive with a single empty string argument 138 | # like in the following example: 139 | # 140 | # save "" 141 | 142 | save "" 143 | 144 | # By default Redis will stop accepting writes if RDB snapshots are enabled 145 | # (at least one save point) and the latest background save failed. 146 | # This will make the user aware (in a hard way) that data is not persisting 147 | # on disk properly, otherwise chances are that no one will notice and some 148 | # disaster will happen. 149 | # 150 | # If the background saving process will start working again Redis will 151 | # automatically allow writes again. 152 | # 153 | # However if you have setup your proper monitoring of the Redis server 154 | # and persistence, you may want to disable this feature so that Redis will 155 | # continue to work as usual even if there are problems with disk, 156 | # permissions, and so forth. 157 | stop-writes-on-bgsave-error yes 158 | 159 | # Compress string objects using LZF when dump .rdb databases? 160 | # For default that's set to 'yes' as it's almost always a win. 161 | # If you want to save some CPU in the saving child set it to 'no' but 162 | # the dataset will likely be bigger if you have compressible values or keys. 163 | rdbcompression yes 164 | 165 | # Since version 5 of RDB a CRC64 checksum is placed at the end of the file. 166 | # This makes the format more resistant to corruption but there is a performance 167 | # hit to pay (around 10%) when saving and loading RDB files, so you can disable it 168 | # for maximum performances. 169 | # 170 | # RDB files created with checksum disabled have a checksum of zero that will 171 | # tell the loading code to skip the check. 172 | rdbchecksum yes 173 | 174 | # The filename where to dump the DB 175 | dbfilename dump.rdb 176 | 177 | # The working directory. 178 | # 179 | # The DB will be written inside this directory, with the filename specified 180 | # above using the 'dbfilename' configuration directive. 181 | # 182 | # The Append Only File will also be created inside this directory. 183 | # 184 | # Note that you must specify a directory here, not a file name. 185 | dir /var/lib/redis 186 | 187 | ################################## SECURITY ################################### 188 | 189 | # Require clients to issue AUTH before processing any other 190 | # commands. This might be useful in environments in which you do not trust 191 | # others with access to the host running redis-server. 192 | # 193 | # This should stay commented out for backward compatibility and because most 194 | # people do not need auth (e.g. they run their own servers). 195 | # 196 | # Warning: since Redis is pretty fast an outside user can try up to 197 | # 150k passwords per second against a good box. This means that you should 198 | # use a very strong password otherwise it will be very easy to break. 199 | # 200 | # requirepass foobared 201 | 202 | # Command renaming. 203 | # 204 | # It is possible to change the name of dangerous commands in a shared 205 | # environment. For instance the CONFIG command may be renamed into something 206 | # hard to guess so that it will still be available for internal-use tools 207 | # but not available for general clients. 208 | # 209 | # Example: 210 | # 211 | # rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52 212 | # 213 | # It is also possible to completely kill a command by renaming it into 214 | # an empty string: 215 | # 216 | # rename-command CONFIG "" 217 | # 218 | # Please note that changing the name of commands that are logged into the 219 | # AOF file or transmitted to slaves may cause problems. 220 | 221 | ################################### LIMITS #################################### 222 | 223 | # Set the max number of connected clients at the same time. By default 224 | # this limit is set to 10000 clients, however if the Redis server is not 225 | # able to configure the process file limit to allow for the specified limit 226 | # the max number of allowed clients is set to the current file limit 227 | # minus 32 (as Redis reserves a few file descriptors for internal uses). 228 | # 229 | # Once the limit is reached Redis will close all the new connections sending 230 | # an error 'max number of clients reached'. 231 | # 232 | maxclients 100 233 | 234 | # Don't use more memory than the specified amount of bytes. 235 | # When the memory limit is reached Redis will try to remove keys 236 | # according to the eviction policy selected (see maxmemory-policy). 237 | # 238 | # If Redis can't remove keys according to the policy, or if the policy is 239 | # set to 'noeviction', Redis will start to reply with errors to commands 240 | # that would use more memory, like SET, LPUSH, and so on, and will continue 241 | # to reply to read-only commands like GET. 242 | # 243 | # This option is usually useful when using Redis as an LRU cache, or to set 244 | # a hard memory limit for an instance (using the 'noeviction' policy). 245 | # 246 | # WARNING: If you have slaves attached to an instance with maxmemory on, 247 | # the size of the output buffers needed to feed the slaves are subtracted 248 | # from the used memory count, so that network problems / resyncs will 249 | # not trigger a loop where keys are evicted, and in turn the output 250 | # buffer of slaves is full with DELs of keys evicted triggering the deletion 251 | # of more keys, and so forth until the database is completely emptied. 252 | # 253 | # In short... if you have slaves attached it is suggested that you set a lower 254 | # limit for maxmemory so that there is some free RAM on the system for slave 255 | # output buffers (but this is not needed if the policy is 'noeviction'). 256 | # 257 | # maxmemory 258 | 259 | # MAXMEMORY POLICY: how Redis will select what to remove when maxmemory 260 | # is reached. You can select among five behaviors: 261 | # 262 | # volatile-lru -> remove the key with an expire set using an LRU algorithm 263 | # allkeys-lru -> remove any key according to the LRU algorithm 264 | # volatile-random -> remove a random key with an expire set 265 | # allkeys-random -> remove a random key, any key 266 | # volatile-ttl -> remove the key with the nearest expire time (minor TTL) 267 | # noeviction -> don't expire at all, just return an error on write operations 268 | # 269 | # Note: with any of the above policies, Redis will return an error on write 270 | # operations, when there are no suitable keys for eviction. 271 | # 272 | # At the date of writing these commands are: set setnx setex append 273 | # incr decr rpush lpush rpushx lpushx linsert lset rpoplpush sadd 274 | # sinter sinterstore sunion sunionstore sdiff sdiffstore zadd zincrby 275 | # zunionstore zinterstore hset hsetnx hmset hincrby incrby decrby 276 | # getset mset msetnx exec sort 277 | # 278 | # The default is: 279 | # 280 | # maxmemory-policy volatile-lru 281 | 282 | # LRU and minimal TTL algorithms are not precise algorithms but approximated 283 | # algorithms (in order to save memory), so you can select as well the sample 284 | # size to check. For instance for default Redis will check three keys and 285 | # pick the one that was used less recently, you can change the sample size 286 | # using the following configuration directive. 287 | # 288 | # maxmemory-samples 3 289 | 290 | ############################## APPEND ONLY MODE ############################### 291 | 292 | # By default Redis asynchronously dumps the dataset on disk. This mode is 293 | # good enough in many applications, but an issue with the Redis process or 294 | # a power outage may result into a few minutes of writes lost (depending on 295 | # the configured save points). 296 | # 297 | # The Append Only File is an alternative persistence mode that provides 298 | # much better durability. For instance using the default data fsync policy 299 | # (see later in the config file) Redis can lose just one second of writes in a 300 | # dramatic event like a server power outage, or a single write if something 301 | # wrong with the Redis process itself happens, but the operating system is 302 | # still running correctly. 303 | # 304 | # AOF and RDB persistence can be enabled at the same time without problems. 305 | # If the AOF is enabled on startup Redis will load the AOF, that is the file 306 | # with the better durability guarantees. 307 | # 308 | # Please check http://redis.io/topics/persistence for more information. 309 | 310 | appendonly yes 311 | 312 | # The name of the append only file (default: "appendonly.aof") 313 | 314 | appendfilename "appendonly.aof" 315 | 316 | # The fsync() call tells the Operating System to actually write data on disk 317 | # instead of waiting for more data in the output buffer. Some OS will really flush 318 | # data on disk, some other OS will just try to do it ASAP. 319 | # 320 | # Redis supports three different modes: 321 | # 322 | # no: don't fsync, just let the OS flush the data when it wants. Faster. 323 | # always: fsync after every write to the append only log. Slow, Safest. 324 | # everysec: fsync only one time every second. Compromise. 325 | # 326 | # The default is "everysec", as that's usually the right compromise between 327 | # speed and data safety. It's up to you to understand if you can relax this to 328 | # "no" that will let the operating system flush the output buffer when 329 | # it wants, for better performances (but if you can live with the idea of 330 | # some data loss consider the default persistence mode that's snapshotting), 331 | # or on the contrary, use "always" that's very slow but a bit safer than 332 | # everysec. 333 | # 334 | # More details please check the following article: 335 | # http://antirez.com/post/redis-persistence-demystified.html 336 | # 337 | # If unsure, use "everysec". 338 | 339 | # appendfsync always 340 | # appendfsync everysec 341 | appendfsync no 342 | 343 | # When the AOF fsync policy is set to always or everysec, and a background 344 | # saving process (a background save or AOF log background rewriting) is 345 | # performing a lot of I/O against the disk, in some Linux configurations 346 | # Redis may block too long on the fsync() call. Note that there is no fix for 347 | # this currently, as even performing fsync in a different thread will block 348 | # our synchronous write(2) call. 349 | # 350 | # In order to mitigate this problem it's possible to use the following option 351 | # that will prevent fsync() from being called in the main process while a 352 | # BGSAVE or BGREWRITEAOF is in progress. 353 | # 354 | # This means that while another child is saving, the durability of Redis is 355 | # the same as "appendfsync none". In practical terms, this means that it is 356 | # possible to lose up to 30 seconds of log in the worst scenario (with the 357 | # default Linux settings). 358 | # 359 | # If you have latency problems turn this to "yes". Otherwise leave it as 360 | # "no" that is the safest pick from the point of view of durability. 361 | 362 | no-appendfsync-on-rewrite yes 363 | 364 | # Automatic rewrite of the append only file. 365 | # Redis is able to automatically rewrite the log file implicitly calling 366 | # BGREWRITEAOF when the AOF log size grows by the specified percentage. 367 | # 368 | # This is how it works: Redis remembers the size of the AOF file after the 369 | # latest rewrite (if no rewrite has happened since the restart, the size of 370 | # the AOF at startup is used). 371 | # 372 | # This base size is compared to the current size. If the current size is 373 | # bigger than the specified percentage, the rewrite is triggered. Also 374 | # you need to specify a minimal size for the AOF file to be rewritten, this 375 | # is useful to avoid rewriting the AOF file even if the percentage increase 376 | # is reached but it is still pretty small. 377 | # 378 | # Specify a percentage of zero in order to disable the automatic AOF 379 | # rewrite feature. 380 | 381 | auto-aof-rewrite-percentage 100 382 | auto-aof-rewrite-min-size 64mb 383 | 384 | # An AOF file may be found to be truncated at the end during the Redis 385 | # startup process, when the AOF data gets loaded back into memory. 386 | # This may happen when the system where Redis is running 387 | # crashes, especially when an ext4 filesystem is mounted without the 388 | # data=ordered option (however this can't happen when Redis itself 389 | # crashes or aborts but the operating system still works correctly). 390 | # 391 | # Redis can either exit with an error when this happens, or load as much 392 | # data as possible (the default now) and start if the AOF file is found 393 | # to be truncated at the end. The following option controls this behavior. 394 | # 395 | # If aof-load-truncated is set to yes, a truncated AOF file is loaded and 396 | # the Redis server starts emitting a log to inform the user of the event. 397 | # Otherwise if the option is set to no, the server aborts with an error 398 | # and refuses to start. When the option is set to no, the user requires 399 | # to fix the AOF file using the "redis-check-aof" utility before to restart 400 | # the server. 401 | # 402 | # Note that if the AOF file will be found to be corrupted in the middle 403 | # the server will still exit with an error. This option only applies when 404 | # Redis will try to read more data from the AOF file but not enough bytes 405 | # will be found. 406 | aof-load-truncated yes 407 | 408 | ################################ LUA SCRIPTING ############################### 409 | 410 | # Max execution time of a Lua script in milliseconds. 411 | # 412 | # If the maximum execution time is reached Redis will log that a script is 413 | # still in execution after the maximum allowed time and will start to 414 | # reply to queries with an error. 415 | # 416 | # When a long running script exceeds the maximum execution time only the 417 | # SCRIPT KILL and SHUTDOWN NOSAVE commands are available. The first can be 418 | # used to stop a script that did not yet called write commands. The second 419 | # is the only way to shut down the server in the case a write command was 420 | # already issued by the script but the user doesn't want to wait for the natural 421 | # termination of the script. 422 | # 423 | # Set it to 0 or a negative value for unlimited execution without warnings. 424 | lua-time-limit 5000 425 | 426 | ################################## SLOW LOG ################################### 427 | 428 | # The Redis Slow Log is a system to log queries that exceeded a specified 429 | # execution time. The execution time does not include the I/O operations 430 | # like talking with the client, sending the reply and so forth, 431 | # but just the time needed to actually execute the command (this is the only 432 | # stage of command execution where the thread is blocked and can not serve 433 | # other requests in the meantime). 434 | # 435 | # You can configure the slow log with two parameters: one tells Redis 436 | # what is the execution time, in microseconds, to exceed in order for the 437 | # command to get logged, and the other parameter is the length of the 438 | # slow log. When a new command is logged the oldest one is removed from the 439 | # queue of logged commands. 440 | 441 | # The following time is expressed in microseconds, so 1000000 is equivalent 442 | # to one second. Note that a negative number disables the slow log, while 443 | # a value of zero forces the logging of every command. 444 | slowlog-log-slower-than 10000 445 | 446 | # There is no limit to this length. Just be aware that it will consume memory. 447 | # You can reclaim memory used by the slow log with SLOWLOG RESET. 448 | slowlog-max-len 128 449 | 450 | ################################ LATENCY MONITOR ############################## 451 | 452 | # The Redis latency monitoring subsystem samples different operations 453 | # at runtime in order to collect data related to possible sources of 454 | # latency of a Redis instance. 455 | # 456 | # Via the LATENCY command this information is available to the user that can 457 | # print graphs and obtain reports. 458 | # 459 | # The system only logs operations that were performed in a time equal or 460 | # greater than the amount of milliseconds specified via the 461 | # latency-monitor-threshold configuration directive. When its value is set 462 | # to zero, the latency monitor is turned off. 463 | # 464 | # By default latency monitoring is disabled since it is mostly not needed 465 | # if you don't have latency issues, and collecting data has a performance 466 | # impact, that while very small, can be measured under big load. Latency 467 | # monitoring can easily be enalbed at runtime using the command 468 | # "CONFIG SET latency-monitor-threshold " if needed. 469 | latency-monitor-threshold 0 470 | 471 | ############################# Event notification ############################## 472 | 473 | # Redis can notify Pub/Sub clients about events happening in the key space. 474 | # This feature is documented at http://redis.io/topics/notifications 475 | # 476 | # For instance if keyspace events notification is enabled, and a client 477 | # performs a DEL operation on key "foo" stored in the Database 0, two 478 | # messages will be published via Pub/Sub: 479 | # 480 | # PUBLISH __keyspace@0__:foo del 481 | # PUBLISH __keyevent@0__:del foo 482 | # 483 | # It is possible to select the events that Redis will notify among a set 484 | # of classes. Every class is identified by a single character: 485 | # 486 | # K Keyspace events, published with __keyspace@__ prefix. 487 | # E Keyevent events, published with __keyevent@__ prefix. 488 | # g Generic commands (non-type specific) like DEL, EXPIRE, RENAME, ... 489 | # $ String commands 490 | # l List commands 491 | # s Set commands 492 | # h Hash commands 493 | # z Sorted set commands 494 | # x Expired events (events generated every time a key expires) 495 | # e Evicted events (events generated when a key is evicted for maxmemory) 496 | # A Alias for g$lshzxe, so that the "AKE" string means all the events. 497 | # 498 | # The "notify-keyspace-events" takes as argument a string that is composed 499 | # of zero or multiple characters. The empty string means that notifications 500 | # are disabled. 501 | # 502 | # Example: to enable list and generic events, from the point of view of the 503 | # event name, use: 504 | # 505 | # notify-keyspace-events Elg 506 | # 507 | # Example 2: to get the stream of the expired keys subscribing to channel 508 | # name __keyevent@0__:expired use: 509 | # 510 | # notify-keyspace-events Ex 511 | # 512 | # By default all notifications are disabled because most users don't need 513 | # this feature and the feature has some overhead. Note that if you don't 514 | # specify at least one of K or E, no events will be delivered. 515 | notify-keyspace-events "" 516 | 517 | ############################### ADVANCED CONFIG ############################### 518 | 519 | # Hashes are encoded using a memory efficient data structure when they have a 520 | # small number of entries, and the biggest entry does not exceed a given 521 | # threshold. These thresholds can be configured using the following directives. 522 | hash-max-ziplist-entries 512 523 | hash-max-ziplist-value 64 524 | 525 | # Similarly to hashes, small lists are also encoded in a special way in order 526 | # to save a lot of space. The special representation is only used when 527 | # you are under the following limits: 528 | list-max-ziplist-entries 512 529 | list-max-ziplist-value 64 530 | 531 | # Sets have a special encoding in just one case: when a set is composed 532 | # of just strings that happen to be integers in radix 10 in the range 533 | # of 64 bit signed integers. 534 | # The following configuration setting sets the limit in the size of the 535 | # set in order to use this special memory saving encoding. 536 | set-max-intset-entries 512 537 | 538 | # Similarly to hashes and lists, sorted sets are also specially encoded in 539 | # order to save a lot of space. This encoding is only used when the length and 540 | # elements of a sorted set are below the following limits: 541 | zset-max-ziplist-entries 128 542 | zset-max-ziplist-value 64 543 | 544 | # HyperLogLog sparse representation bytes limit. The limit includes the 545 | # 16 bytes header. When an HyperLogLog using the sparse representation crosses 546 | # this limit, it is converted into the dense representation. 547 | # 548 | # A value greater than 16000 is totally useless, since at that point the 549 | # dense representation is more memory efficient. 550 | # 551 | # The suggested value is ~ 3000 in order to have the benefits of 552 | # the space efficient encoding without slowing down too much PFADD, 553 | # which is O(N) with the sparse encoding. The value can be raised to 554 | # ~ 10000 when CPU is not a concern, but space is, and the data set is 555 | # composed of many HyperLogLogs with cardinality in the 0 - 15000 range. 556 | hll-sparse-max-bytes 3000 557 | 558 | # Active rehashing uses 1 millisecond every 100 milliseconds of CPU time in 559 | # order to help rehashing the main Redis hash table (the one mapping top-level 560 | # keys to values). The hash table implementation Redis uses (see dict.c) 561 | # performs a lazy rehashing: the more operation you run into a hash table 562 | # that is rehashing, the more rehashing "steps" are performed, so if the 563 | # server is idle the rehashing is never complete and some more memory is used 564 | # by the hash table. 565 | # 566 | # The default is to use this millisecond 10 times every second in order to 567 | # actively rehash the main dictionaries, freeing memory when possible. 568 | # 569 | # If unsure: 570 | # use "activerehashing no" if you have hard latency requirements and it is 571 | # not a good thing in your environment that Redis can reply from time to time 572 | # to queries with 2 milliseconds delay. 573 | # 574 | # use "activerehashing yes" if you don't have such hard requirements but 575 | # want to free memory asap when possible. 576 | activerehashing no 577 | 578 | # The client output buffer limits can be used to force disconnection of clients 579 | # that are not reading data from the server fast enough for some reason (a 580 | # common reason is that a Pub/Sub client can't consume messages as fast as the 581 | # publisher can produce them). 582 | # 583 | # The limit can be set differently for the three different classes of clients: 584 | # 585 | # normal -> normal clients including MONITOR clients 586 | # slave -> slave clients 587 | # pubsub -> clients subscribed to at least one pubsub channel or pattern 588 | # 589 | # The syntax of every client-output-buffer-limit directive is the following: 590 | # 591 | # client-output-buffer-limit 592 | # 593 | # A client is immediately disconnected once the hard limit is reached, or if 594 | # the soft limit is reached and remains reached for the specified number of 595 | # seconds (continuously). 596 | # So for instance if the hard limit is 32 megabytes and the soft limit is 597 | # 16 megabytes / 10 seconds, the client will get disconnected immediately 598 | # if the size of the output buffers reach 32 megabytes, but will also get 599 | # disconnected if the client reaches 16 megabytes and continuously overcomes 600 | # the limit for 10 seconds. 601 | # 602 | # By default normal clients are not limited because they don't receive data 603 | # without asking (in a push way), but just after a request, so only 604 | # asynchronous clients may create a scenario where data is requested faster 605 | # than it can read. 606 | # 607 | # Instead there is a default limit for pubsub and slave clients, since 608 | # subscribers and slaves receive data in a push fashion. 609 | # 610 | # Both the hard or the soft limit can be disabled by setting them to zero. 611 | client-output-buffer-limit normal 0 0 0 612 | client-output-buffer-limit slave 256mb 64mb 60 613 | client-output-buffer-limit pubsub 32mb 8mb 60 614 | 615 | # Redis calls an internal function to perform many background tasks, like 616 | # closing connections of clients in timeout, purging expired keys that are 617 | # never requested, and so forth. 618 | # 619 | # Not all tasks are performed with the same frequency, but Redis checks for 620 | # tasks to perform according to the specified "hz" value. 621 | # 622 | # By default "hz" is set to 10. Raising the value will use more CPU when 623 | # Redis is idle, but at the same time will make Redis more responsive when 624 | # there are many keys expiring at the same time, and timeouts may be 625 | # handled with more precision. 626 | # 627 | # The range is between 1 and 500, however a value over 100 is usually not 628 | # a good idea. Most users should use the default of 10 and raise this up to 629 | # 100 only in environments where very low latency is required. 630 | hz 1 631 | 632 | # When a child rewrites the AOF file, if the following option is enabled 633 | # the file will be fsync-ed every 32 MB of data generated. This is useful 634 | # in order to commit the file to the disk more incrementally and avoid 635 | # big latency spikes. 636 | aof-rewrite-incremental-fsync no 637 | -------------------------------------------------------------------------------- /supervisor/conf.d/arping.conf: -------------------------------------------------------------------------------- 1 | [program:arping] 2 | command=bash -c 'IP=$(ip -4 addr show dev eth0 scope global | sed -nr "s/.*inet ([^/]+).*/\1/p"); /usr/bin/arping -U -c 4 $IP' 3 | autorestart=false 4 | autostart=true 5 | -------------------------------------------------------------------------------- /supervisor/conf.d/cron.conf: -------------------------------------------------------------------------------- 1 | [program:cron] 2 | command=/usr/sbin/cron -f 3 | autorestart=true 4 | -------------------------------------------------------------------------------- /supervisor/conf.d/redis.conf: -------------------------------------------------------------------------------- 1 | [program:redis] 2 | command=/usr/bin/redis-server /etc/redis/redis.conf --daemonize no 3 | autorestart=unexpected 4 | startsecs=60 5 | startretries=3 6 | -------------------------------------------------------------------------------- /supervisor/supervisord.conf: -------------------------------------------------------------------------------- 1 | [unix_http_server] 2 | file=/var/run/supervisor.sock ; (the path to the socket file) 3 | chmod=0700 ; sockef file mode (default 0700) 4 | 5 | [supervisord] 6 | logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log) 7 | pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid) 8 | childlogdir=/var/log/supervisor ; ('AUTO' child log dir, default $TEMP) 9 | logfile_maxbytes=10MB ; (max main logfile bytes b4 rotation;default 50MB) 10 | logfile_backups=10 ; (num of main logfile rotation backups;default 10) 11 | loglevel=debug ; (log level;default info; others: debug,warn,trace) 12 | nodaemon=true ; (start in foreground if true;default false) 13 | 14 | [rpcinterface:supervisor] 15 | supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface 16 | 17 | [supervisorctl] 18 | serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL for a unix socket 19 | 20 | [include] 21 | files = /etc/supervisor/conf.d/*.conf 22 | --------------------------------------------------------------------------------