pkg-wizard 0.1.14 → 0.1.15
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/pkg-wizard/commands/build_bot.rb +40 -1
- data/lib/pkg-wizard/utils.rb +23 -0
- data/lib/pkg-wizard.rb +1 -1
- metadata +5 -4
@@ -3,6 +3,7 @@ require 'pkg-wizard/rpm'
|
|
3
3
|
require 'pkg-wizard/logger'
|
4
4
|
require 'pkg-wizard/git'
|
5
5
|
require 'pkg-wizard/mock'
|
6
|
+
require 'pkg-wizard/utils'
|
6
7
|
require 'tmpdir'
|
7
8
|
require 'fileutils'
|
8
9
|
require 'uri'
|
@@ -46,6 +47,17 @@ module PKGWizard
|
|
46
47
|
post '/createsnapshot' do
|
47
48
|
FileUtils.touch 'snapshot/.createsnapshot'
|
48
49
|
end
|
50
|
+
|
51
|
+
post '/job/clean' do
|
52
|
+
dir = params[:dir] || 'output'
|
53
|
+
if dir == 'output'
|
54
|
+
FileUtils.touch 'output/.clean'
|
55
|
+
elsif dir == 'failed'
|
56
|
+
FileUtils.touch 'failed/.clean'
|
57
|
+
else
|
58
|
+
$stderr.puts "WARNING: job/clean Unknown dir #{dir}. Ignoring."
|
59
|
+
end
|
60
|
+
end
|
49
61
|
|
50
62
|
post '/build/' do
|
51
63
|
pkg = params[:pkg]
|
@@ -73,8 +85,16 @@ module PKGWizard
|
|
73
85
|
end
|
74
86
|
end
|
75
87
|
|
88
|
+
get '/server/stats' do
|
89
|
+
fs = PKGWizard::Utils.filesystem_status
|
90
|
+
{
|
91
|
+
:filesystem => fs,
|
92
|
+
}.to_yaml
|
93
|
+
end
|
94
|
+
|
76
95
|
get '/job/stats' do
|
77
96
|
fjobs = Dir["failed/job*"].size
|
97
|
+
snapshots = Dir["snapshot/snapshot*"].size
|
78
98
|
sjobs = Dir["output/job*"].size
|
79
99
|
qjobs = Dir["incoming/*.src.rpm"].size
|
80
100
|
total_jobs = fjobs + sjobs
|
@@ -82,7 +102,8 @@ module PKGWizard
|
|
82
102
|
:failed_jobs => fjobs,
|
83
103
|
:successful_jobs => sjobs,
|
84
104
|
:enqueued => qjobs,
|
85
|
-
:total_jobs => total_jobs
|
105
|
+
:total_jobs => total_jobs,
|
106
|
+
:snapshots => snapshots
|
86
107
|
}.to_yaml
|
87
108
|
end
|
88
109
|
|
@@ -171,6 +192,24 @@ module PKGWizard
|
|
171
192
|
Dir.mkdir 'snapshot' if not File.exist?('snapshot')
|
172
193
|
FileUtils.ln_sf 'output', 'repo' if not File.exist?('repo')
|
173
194
|
|
195
|
+
cleaner = Rufus::Scheduler.start_new
|
196
|
+
cleaner.every '2s', :blocking => true do
|
197
|
+
if File.exist?('failed/.clean')
|
198
|
+
$stdout.puts '* cleaning FAILED jobs'
|
199
|
+
Dir["failed/job_*"].each do |d|
|
200
|
+
FileUtils.rm_rf d
|
201
|
+
end
|
202
|
+
FileUtils.rm 'failed/.clean'
|
203
|
+
end
|
204
|
+
if File.exist?('output/.clean')
|
205
|
+
$stdout.puts '* cleaning OUTPUT jobs'
|
206
|
+
Dir["output/job_*"].each do |d|
|
207
|
+
FileUtils.rm_rf d
|
208
|
+
end
|
209
|
+
FileUtils.rm 'output/.clean'
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
174
213
|
# createrepo snapshot
|
175
214
|
snapshot_sched = Rufus::Scheduler.start_new
|
176
215
|
snapshot_sched.every '2s', :blocking => true do
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module PKGWizard
|
2
|
+
module Utils
|
3
|
+
def self.filesystem_status
|
4
|
+
fs = {}
|
5
|
+
`df -P`.each_line do |line|
|
6
|
+
case line
|
7
|
+
when /^Filesystem\s+1024-blocks/
|
8
|
+
next
|
9
|
+
when /^(.+?)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+\%)\s+(.+)$/
|
10
|
+
next if %{none tmpfs usbfs debugfs}.include? $1
|
11
|
+
filesystem = $1
|
12
|
+
fs[filesystem] = {}
|
13
|
+
fs[filesystem][:kb_size] = $2
|
14
|
+
fs[filesystem][:kb_used] = $3
|
15
|
+
fs[filesystem][:kb_available] = $4
|
16
|
+
fs[filesystem][:percent_used] = $5
|
17
|
+
fs[filesystem][:mount] = $6
|
18
|
+
end
|
19
|
+
end
|
20
|
+
fs
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/pkg-wizard.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pkg-wizard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 5
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 15
|
10
|
+
version: 0.1.15
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sergio Rubio
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-03-
|
18
|
+
date: 2011-03-10 00:00:00 +01:00
|
19
19
|
default_executable: pkgwiz
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -190,6 +190,7 @@ files:
|
|
190
190
|
- lib/pkg-wizard/rpm.rb
|
191
191
|
- lib/pkg-wizard/streaming_downloader.rb
|
192
192
|
- lib/pkg-wizard/streaming_uploader.rb
|
193
|
+
- lib/pkg-wizard/utils.rb
|
193
194
|
- packages/epel-release-5-4.noarch.rpm
|
194
195
|
- packages/epel-release-6-5.noarch.rpm
|
195
196
|
has_rdoc: true
|