perus 0.1.14 → 0.1.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/perus/server/db.rb +6 -38
- data/lib/perus/server/stats.rb +3 -1
- data/lib/perus/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 733c49d83f2675c9e1a47508ca3694f14a946803
|
4
|
+
data.tar.gz: 93067c4ab61180c3fc09ef70cf1315be28e5eab4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f396acf003664d9c11cb6d40aed7ad545f4a683e68895ee8c1a803350d8dc79d954f9d60bc2e282a32d0a10dc702f3a4dbacaf646c31a0815a3a86261336c6cb
|
7
|
+
data.tar.gz: db0c3585362f6226cb32a523271b980fe82f2932243c474eae216ddf4c522a4336fa09e5d3f3cf736030e9f9f5b44f82c3cd09751991fb44ddb449b7a08e369c
|
data/lib/perus/server/db.rb
CHANGED
@@ -17,7 +17,7 @@ module Perus::Server
|
|
17
17
|
Sequel.extension :inflector
|
18
18
|
|
19
19
|
# connect/create the database and run any new migrations
|
20
|
-
@db = Sequel.
|
20
|
+
@db = Sequel.postgres('perus', host: 'localhost')
|
21
21
|
Sequel::Migrator.run(@db, File.join(__dir__, 'migrations'))
|
22
22
|
|
23
23
|
# load models - these rely on an existing db connection
|
@@ -39,43 +39,6 @@ module Perus::Server
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def self.start_timers
|
42
|
-
# attempt to run vacuum twice a day. this is done to increase
|
43
|
-
# performance rather than reclaim unused space. as old values and
|
44
|
-
# metrics are deleted the data become very fragmented. vacuuming
|
45
|
-
# restructures the db so system records in the values index should
|
46
|
-
# be sequentially stored
|
47
|
-
vacuum_task = Concurrent::TimerTask.new do
|
48
|
-
attempts = 0
|
49
|
-
complete = false
|
50
|
-
|
51
|
-
while !complete && attempts < MAX_VACUUM_ATTEMPTS
|
52
|
-
begin
|
53
|
-
puts "Vacuuming, attempt #{attempts + 1}"
|
54
|
-
start = Time.now
|
55
|
-
@db.execute('vacuum')
|
56
|
-
Stats.vacuumed!(Time.now - start)
|
57
|
-
complete = true
|
58
|
-
puts "Vacuuming complete"
|
59
|
-
|
60
|
-
rescue
|
61
|
-
attempts += 1
|
62
|
-
if attempts < MAX_VACUUM_ATTEMPTS
|
63
|
-
puts "Vacuum failed, will reattempt after short sleep"
|
64
|
-
sleep(5)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
if !complete
|
70
|
-
puts "Vacuum failed more than MAX_VACUUM_ATTEMPTS"
|
71
|
-
Stats.vacuumed!('failed')
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
# fire every 12 hours
|
76
|
-
vacuum_task.execution_interval = 60 * 60 * 12
|
77
|
-
vacuum_task.execute
|
78
|
-
|
79
42
|
# a fixed number of hours of data are kept in the database. once an
|
80
43
|
# hour, old values and files are removed. if all values of a metric
|
81
44
|
# are removed from a system, the accompanying metric record is also
|
@@ -90,6 +53,11 @@ module Perus::Server
|
|
90
53
|
start = Time.now
|
91
54
|
Perus::Server::DB.cleanup
|
92
55
|
Stats.cleaned!(Time.now - start)
|
56
|
+
|
57
|
+
start = Time.now
|
58
|
+
@db.execute('vacuum')
|
59
|
+
Stats.vacuumed!(Time.now - start)
|
60
|
+
|
93
61
|
complete = true
|
94
62
|
puts "Cleaning complete"
|
95
63
|
|
data/lib/perus/server/stats.rb
CHANGED
data/lib/perus/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: perus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Will Cannings
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|