perus 0.1.14 → 0.1.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3df40bd6deb3e165e357bb4227dbe0b834d33bf5
4
- data.tar.gz: 4c31499544a9d3e97bd3fb7e99308df0cbe4776f
3
+ metadata.gz: 733c49d83f2675c9e1a47508ca3694f14a946803
4
+ data.tar.gz: 93067c4ab61180c3fc09ef70cf1315be28e5eab4
5
5
  SHA512:
6
- metadata.gz: 44f0105e7f52fb732e0effef6635ba31150af32db4daecee4e2e54b9618e2bec66c4ebd94a9854a32de21154b0b83342b54133698165ee0401e061482c28b56d
7
- data.tar.gz: e08dce48e0555f801f3646b67de6489a0f44024409440e2f7a0bae229de4a7a304b644988104a2049fde254e3415948e123fb775442ab7d6041f867e746769c4
6
+ metadata.gz: f396acf003664d9c11cb6d40aed7ad545f4a683e68895ee8c1a803350d8dc79d954f9d60bc2e282a32d0a10dc702f3a4dbacaf646c31a0815a3a86261336c6cb
7
+ data.tar.gz: db0c3585362f6226cb32a523271b980fe82f2932243c474eae216ddf4c522a4336fa09e5d3f3cf736030e9f9f5b44f82c3cd09751991fb44ddb449b7a08e369c
@@ -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.sqlite(Server.options.db_path, integer_booleans: true)
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
 
@@ -30,7 +30,9 @@ module Perus::Server
30
30
  end
31
31
 
32
32
  def save
33
- IO.write(Server.options.stats_path, JSON.dump(@data))
33
+ File.open(Server.options.stats_path, 'w') do |f|
34
+ f.write(JSON.dump(@data))
35
+ end
34
36
  end
35
37
 
36
38
  # vacuuming
data/lib/perus/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Perus
2
- VERSION = "0.1.14"
2
+ VERSION = "0.1.15"
3
3
  end
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.14
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-12 00:00:00.000000000 Z
11
+ date: 2015-07-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler