boned 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.txt +5 -0
- data/bin/boned +1 -0
- data/boned.gemspec +2 -1
- data/config/redis-server.conf +177 -0
- data/lib/boned/cli.rb +8 -4
- data/lib/boned/models/bone.rb +0 -1
- data/lib/boned.rb +12 -8
- metadata +2 -1
data/CHANGES.txt
CHANGED
data/bin/boned
CHANGED
data/boned.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
@spec = Gem::Specification.new do |s|
|
2
2
|
s.name = "boned"
|
3
3
|
s.rubyforge_project = 'boned'
|
4
|
-
s.version = "0.2.
|
4
|
+
s.version = "0.2.2"
|
5
5
|
s.summary = "The bone daemon"
|
6
6
|
s.description = s.summary
|
7
7
|
s.author = "Delano Mandelbaum"
|
@@ -27,6 +27,7 @@
|
|
27
27
|
bin/boned
|
28
28
|
boned.gemspec
|
29
29
|
config.ru
|
30
|
+
config/redis-server.conf
|
30
31
|
lib/boned.rb
|
31
32
|
lib/boned/api.rb
|
32
33
|
lib/boned/api/debug.rb
|
@@ -0,0 +1,177 @@
|
|
1
|
+
# Redis configuration file for Boned
|
2
|
+
|
3
|
+
# Changes:
|
4
|
+
# * port
|
5
|
+
# * daemonize
|
6
|
+
# * dbfilename
|
7
|
+
|
8
|
+
# By default Redis does not run as a daemon. Use 'yes' if you need it.
|
9
|
+
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
|
10
|
+
daemonize yes
|
11
|
+
|
12
|
+
# The filename where to dump the DB
|
13
|
+
dbfilename /tmp/boned-redis.rdb
|
14
|
+
|
15
|
+
# When run as a daemon, Redis write a pid file in /var/run/redis.pid by default.
|
16
|
+
# You can specify a custom pid file location here.
|
17
|
+
pidfile /var/run/redis.pid
|
18
|
+
|
19
|
+
# Accept connections on the specified port, default is 6379
|
20
|
+
port 8045
|
21
|
+
|
22
|
+
# If you want you can bind a single interface, if the bind option is not
|
23
|
+
# specified all the interfaces will listen for connections.
|
24
|
+
#
|
25
|
+
# bind 127.0.0.1
|
26
|
+
|
27
|
+
# Close the connection after a client is idle for N seconds (0 to disable)
|
28
|
+
timeout 300
|
29
|
+
|
30
|
+
# Save the DB on disk:
|
31
|
+
#
|
32
|
+
# save <seconds> <changes>
|
33
|
+
#
|
34
|
+
# Will save the DB if both the given number of seconds and the given
|
35
|
+
# number of write operations against the DB occurred.
|
36
|
+
#
|
37
|
+
# In the example below the behaviour will be to save:
|
38
|
+
# after 900 sec (15 min) if at least 1 key changed
|
39
|
+
# after 300 sec (5 min) if at least 10 keys changed
|
40
|
+
# after 60 sec if at least 10000 keys changed
|
41
|
+
save 600 1
|
42
|
+
save 300 10
|
43
|
+
save 60 10000
|
44
|
+
|
45
|
+
|
46
|
+
# For default save/load DB in/from the working directory
|
47
|
+
# Note that you must specify a directory not a file name.
|
48
|
+
dir ./
|
49
|
+
|
50
|
+
# Set server verbosity to 'debug'
|
51
|
+
# it can be one of:
|
52
|
+
# debug (a lot of information, useful for development/testing)
|
53
|
+
# notice (moderately verbose, what you want in production probably)
|
54
|
+
# warning (only very important / critical messages are logged)
|
55
|
+
loglevel debug
|
56
|
+
|
57
|
+
# Specify the log file name. Also 'stdout' can be used to force
|
58
|
+
# the demon to log on the standard output. Note that if you use standard
|
59
|
+
# output for logging but daemonize, logs will be sent to /dev/null
|
60
|
+
logfile stdout
|
61
|
+
|
62
|
+
# Set the number of databases. The default database is DB 0, you can select
|
63
|
+
# a different one on a per-connection basis using SELECT <dbid> where
|
64
|
+
# dbid is a number between 0 and 'databases'-1
|
65
|
+
databases 16
|
66
|
+
|
67
|
+
################################# REPLICATION #################################
|
68
|
+
|
69
|
+
# Master-Slave replication. Use slaveof to make a Redis instance a copy of
|
70
|
+
# another Redis server. Note that the configuration is local to the slave
|
71
|
+
# so for example it is possible to configure the slave to save the DB with a
|
72
|
+
# different interval, or to listen to another port, and so on.
|
73
|
+
|
74
|
+
# slaveof <masterip> <masterport>
|
75
|
+
|
76
|
+
################################## SECURITY ###################################
|
77
|
+
|
78
|
+
# Require clients to issue AUTH <PASSWORD> before processing any other
|
79
|
+
# commands. This might be useful in environments in which you do not trust
|
80
|
+
# others with access to the host running redis-server.
|
81
|
+
#
|
82
|
+
# This should stay commented out for backward compatibility and because most
|
83
|
+
# people do not need auth (e.g. they run their own servers).
|
84
|
+
|
85
|
+
# requirepass
|
86
|
+
|
87
|
+
################################### LIMITS ####################################
|
88
|
+
|
89
|
+
# Set the max number of connected clients at the same time. By default there
|
90
|
+
# is no limit, and it's up to the number of file descriptors the Redis process
|
91
|
+
# is able to open. The special value '0' means no limts.
|
92
|
+
# Once the limit is reached Redis will close all the new connections sending
|
93
|
+
# an error 'max number of clients reached'.
|
94
|
+
|
95
|
+
# maxclients 128
|
96
|
+
|
97
|
+
# Don't use more memory than the specified amount of bytes.
|
98
|
+
# When the memory limit is reached Redis will try to remove keys with an
|
99
|
+
# EXPIRE set. It will try to start freeing keys that are going to expire
|
100
|
+
# in little time and preserve keys with a longer time to live.
|
101
|
+
# Redis will also try to remove objects from free lists if possible.
|
102
|
+
#
|
103
|
+
# If all this fails, Redis will start to reply with errors to commands
|
104
|
+
# that will use more memory, like SET, LPUSH, and so on, and will continue
|
105
|
+
# to reply to most read-only commands like GET.
|
106
|
+
#
|
107
|
+
# WARNING: maxmemory can be a good idea mainly if you want to use Redis as a
|
108
|
+
# 'state' server or cache, not as a real DB. When Redis is used as a real
|
109
|
+
# database the memory usage will grow over the weeks, it will be obvious if
|
110
|
+
# it is going to use too much memory in the long run, and you'll have the time
|
111
|
+
# to upgrade. With maxmemory after the limit is reached you'll start to get
|
112
|
+
# errors for write operations, and this may even lead to DB inconsistency.
|
113
|
+
|
114
|
+
# maxmemory <bytes>
|
115
|
+
|
116
|
+
############################## APPEND ONLY MODE ###############################
|
117
|
+
|
118
|
+
# By default Redis asynchronously dumps the dataset on disk. If you can live
|
119
|
+
# with the idea that the latest records will be lost if something like a crash
|
120
|
+
# happens this is the preferred way to run Redis. If instead you care a lot
|
121
|
+
# about your data and don't want to that a single record can get lost you should
|
122
|
+
# enable the append only mode: when this mode is enabled Redis will append
|
123
|
+
# every write operation received in the file appendonly.log. This file will
|
124
|
+
# be read on startup in order to rebuild the full dataset in memory.
|
125
|
+
#
|
126
|
+
# Note that you can have both the async dumps and the append only file if you
|
127
|
+
# like (you have to comment the "save" statements above to disable the dumps).
|
128
|
+
# Still if append only mode is enabled Redis will load the data from the
|
129
|
+
# log file at startup ignoring the dump.rdb file.
|
130
|
+
#
|
131
|
+
# The name of the append only file is "appendonly.log"
|
132
|
+
|
133
|
+
appendonly no
|
134
|
+
|
135
|
+
# The fsync() call tells the Operating System to actually write data on disk
|
136
|
+
# instead to wait for more data in the output buffer. Some OS will really flush
|
137
|
+
# data on disk, some other OS will just try to do it ASAP.
|
138
|
+
#
|
139
|
+
# Redis supports three different modes:
|
140
|
+
#
|
141
|
+
# no: don't fsync, just let the OS flush the data when it wants. Faster.
|
142
|
+
# always: fsync after every write to the append only log . Slow, Safest.
|
143
|
+
# everysec: fsync only if one second passed since the last fsync. Compromise.
|
144
|
+
#
|
145
|
+
# The default is "always" that's the safer of the options. It's up to you to
|
146
|
+
# understand if you can relax this to "everysec" that will fsync every second
|
147
|
+
# or to "no" that will let the operating system flush the output buffer when
|
148
|
+
# it want, for better performances (but if you can live with the idea of
|
149
|
+
# some data loss consider the default persistence mode that's snapshotting).
|
150
|
+
|
151
|
+
appendfsync always
|
152
|
+
# appendfsync everysec
|
153
|
+
# appendfsync no
|
154
|
+
|
155
|
+
############################### ADVANCED CONFIG ###############################
|
156
|
+
|
157
|
+
# Glue small output buffers together in order to send small replies in a
|
158
|
+
# single TCP packet. Uses a bit more CPU but most of the times it is a win
|
159
|
+
# in terms of number of queries per second. Use 'yes' if unsure.
|
160
|
+
glueoutputbuf yes
|
161
|
+
|
162
|
+
# Use object sharing. Can save a lot of memory if you have many common
|
163
|
+
# string in your dataset, but performs lookups against the shared objects
|
164
|
+
# pool so it uses more CPU and can be a bit slower. Usually it's a good
|
165
|
+
# idea.
|
166
|
+
#
|
167
|
+
# When object sharing is enabled (shareobjects yes) you can use
|
168
|
+
# shareobjectspoolsize to control the size of the pool used in order to try
|
169
|
+
# object sharing. A bigger pool size will lead to better sharing capabilities.
|
170
|
+
# In general you want this value to be at least the double of the number of
|
171
|
+
# very common strings you have in your dataset.
|
172
|
+
#
|
173
|
+
# WARNING: object sharing is experimental, don't enable this feature
|
174
|
+
# in production before of Redis 1.0-stable. Still please try this feature in
|
175
|
+
# your development environment so that we can test it better.
|
176
|
+
shareobjects no
|
177
|
+
shareobjectspoolsize 1024
|
data/lib/boned/cli.rb
CHANGED
@@ -4,11 +4,9 @@ require 'pp'
|
|
4
4
|
class Boned::CLI < Drydock::Command
|
5
5
|
attr_accessor :exit_code
|
6
6
|
|
7
|
-
def init
|
8
|
-
Boned.connect
|
9
|
-
end
|
10
7
|
|
11
8
|
def start
|
9
|
+
Boned.connect
|
12
10
|
if Boned.service_available?('127.0.0.1', server_opts[:port])
|
13
11
|
raise Boned::Server::ServerRunning, server_opts[:port]
|
14
12
|
end
|
@@ -16,13 +14,19 @@ class Boned::CLI < Drydock::Command
|
|
16
14
|
end
|
17
15
|
|
18
16
|
def stop
|
19
|
-
Boned.
|
17
|
+
Boned.connect(false)
|
18
|
+
Boned.stop_redis
|
20
19
|
if not Boned.service_available?('127.0.0.1', server_opts[:port])
|
21
20
|
raise Boned::Server::ServerNotRunning, server_opts[:port]
|
22
21
|
end
|
23
22
|
Boned::Controllers::Controller.new(server_opts).stop
|
24
23
|
end
|
25
24
|
|
25
|
+
def stop_redis
|
26
|
+
Boned.connect(false)
|
27
|
+
Boned.stop_redis
|
28
|
+
end
|
29
|
+
|
26
30
|
def info
|
27
31
|
require 'yaml'
|
28
32
|
if Boned.service_available?('127.0.0.1', server_opts[:port])
|
data/lib/boned/models/bone.rb
CHANGED
data/lib/boned.rb
CHANGED
@@ -23,7 +23,7 @@ module Boned
|
|
23
23
|
module VERSION
|
24
24
|
MAJOR = 0
|
25
25
|
MINOR = 2
|
26
|
-
TINY =
|
26
|
+
TINY = 2
|
27
27
|
PATCH = '001'
|
28
28
|
def self.inspect; [to_s, PATCH].join('.'); end
|
29
29
|
def self.to_s; [MAJOR, MINOR, TINY].join('.'); end
|
@@ -55,15 +55,18 @@ module Boned
|
|
55
55
|
end
|
56
56
|
|
57
57
|
# Connect to Redis and Mongo.
|
58
|
-
def self.connect
|
58
|
+
def self.connect(start_redis=true)
|
59
59
|
update_redis_client_config
|
60
|
-
|
61
|
-
|
60
|
+
ld "CONNECT: start_redis(#{start_redis})"
|
61
|
+
if start_redis
|
62
|
+
self.start_redis
|
63
|
+
abort "No Redis" unless redis_available?
|
64
|
+
end
|
62
65
|
@redis = Redis.new @conf[:redis]
|
63
66
|
end
|
64
67
|
|
65
68
|
def self.start_redis
|
66
|
-
return
|
69
|
+
return if redis_available?
|
67
70
|
conf_path = File.join(BONED_HOME, 'config', 'redis-server.conf')
|
68
71
|
ld "REDIS SERVER CONF: #{conf_path}"
|
69
72
|
@redis_thread = Thread.new do
|
@@ -73,10 +76,11 @@ module Boned
|
|
73
76
|
end
|
74
77
|
|
75
78
|
def self.stop_redis
|
76
|
-
ld "SHUTDOWN REDIS"
|
77
|
-
@redis.
|
79
|
+
ld "SHUTDOWN REDIS #{redis_available?}"
|
80
|
+
ld @redis.inspect
|
81
|
+
# Shutdown command returns "-ERR operation not permitted" ??
|
82
|
+
@redis.shutdown if !@redis.nil? && redis_available? rescue nil
|
78
83
|
return if @redis_thread.nil? || !@redis_thread.alive?
|
79
|
-
@redis_thread.join
|
80
84
|
end
|
81
85
|
|
82
86
|
# <tt>require</tt> a library from the vendor directory.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: boned
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Delano Mandelbaum
|
@@ -33,6 +33,7 @@ files:
|
|
33
33
|
- bin/boned
|
34
34
|
- boned.gemspec
|
35
35
|
- config.ru
|
36
|
+
- config/redis-server.conf
|
36
37
|
- lib/boned.rb
|
37
38
|
- lib/boned/api.rb
|
38
39
|
- lib/boned/api/debug.rb
|