ginst 2009.11.23 → 2009.11.24
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.
- data/VERSION +1 -1
- data/app/models/task.rb +8 -16
- data/config/database.yml +6 -22
- data/config/environment.rb +2 -0
- data/db/migrate/20091025165305_create_tasks.rb +1 -1
- data/db/schema.rb +4 -4
- data/ginst.gemspec +1 -1
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2009.11.
|
1
|
+
2009.11.24
|
data/app/models/task.rb
CHANGED
@@ -86,23 +86,19 @@ class Task < ActiveRecord::Base
|
|
86
86
|
def execute
|
87
87
|
raise TaskAlreadyExecuteException if reload[:ended_at]
|
88
88
|
raise TaskAlreadyRunningException if reload[:started_at]
|
89
|
-
logger "Executing task #{id} named #{name}"
|
90
89
|
status = 'fail'
|
91
90
|
|
92
91
|
ObjectSpace.define_finalizer(self,lambda{
|
93
92
|
update_attributes(:status => 'fail', :ended_at => Time.current, :exit_code => 66)
|
94
93
|
})
|
95
94
|
|
96
|
-
Rails.logger.debug "Running #{name.to_s+' '}task for #{project.slug}"
|
97
95
|
update_attributes(:started_at => Time.current, :status => 'building')
|
98
|
-
|
96
|
+
logger "Executing task #{id} named #{name}"
|
99
97
|
run!
|
100
98
|
run_callbacks!
|
99
|
+
logger "Finished executing tasks"
|
101
100
|
|
102
|
-
status = (exit_code == 0 ? 'success' : 'fail')
|
103
|
-
|
104
|
-
Rails.logger.debug "Finishing running #{name} task for #{project.slug}"
|
105
|
-
|
101
|
+
status = (exit_code == 0 ? 'success' : 'fail')
|
106
102
|
rescue => e
|
107
103
|
puts e.inspect
|
108
104
|
puts e.backtrace
|
@@ -116,7 +112,6 @@ class Task < ActiveRecord::Base
|
|
116
112
|
|
117
113
|
class UnknowTaskFormat < Exception ; end
|
118
114
|
def run!
|
119
|
-
logger.info("task.run!")
|
120
115
|
case
|
121
116
|
when ruby_code?
|
122
117
|
run_ruby!
|
@@ -145,7 +140,7 @@ class Task < ActiveRecord::Base
|
|
145
140
|
|
146
141
|
def run_shell!
|
147
142
|
buff = ''
|
148
|
-
|
143
|
+
logger "Running #{code}"
|
149
144
|
process_status = Open4.popen4(code) do |pid, stdin, stdout, stderr|
|
150
145
|
update_attributes(:pid => pid)
|
151
146
|
|
@@ -154,21 +149,18 @@ class Task < ActiveRecord::Base
|
|
154
149
|
while ( !inputs.empty? ) do
|
155
150
|
select(inputs).first.each do |input|
|
156
151
|
begin
|
157
|
-
|
158
|
-
|
159
|
-
buff += read
|
160
|
-
self.update_attribute(:output, buff) if output != buff && Time.now.to_i > updated_at.to_i + DATABASE_UPDATE_INTERVAL
|
152
|
+
buff += input.read_nonblock(99999999)
|
153
|
+
update_attribute(:output, buff) if output != buff && Time.now.to_i > updated_at.to_i + DATABASE_UPDATE_INTERVAL
|
161
154
|
rescue EOFError
|
162
155
|
logger "EOFError. removing #{stdout == input ? 'stdout' : 'stderr'} input"
|
163
156
|
inputs.delete input
|
164
157
|
end
|
165
158
|
end
|
166
159
|
end
|
160
|
+
update_attribute(:output, buff) if output != buff
|
161
|
+
|
167
162
|
|
168
163
|
end
|
169
|
-
logger "Finished popen"
|
170
|
-
Process.wait
|
171
|
-
logger "Really finished command"
|
172
164
|
process_status.exitstatus
|
173
165
|
ensure
|
174
166
|
self.update_attributes(:output => buff,:pid => nil, :exit_code => (process_status && process_status.exitstatus))
|
data/config/database.yml
CHANGED
@@ -1,32 +1,16 @@
|
|
1
|
-
|
2
|
-
adapter: mysql
|
3
|
-
encoding: utf8
|
4
|
-
database: ginst_development
|
5
|
-
pool: 5
|
6
|
-
username: root
|
7
|
-
password:
|
8
|
-
socket: /tmp/mysql.sock
|
9
|
-
|
10
|
-
# Warning: The database defined as "test" will be erased and
|
11
|
-
# re-generated from your development database when you run "rake".
|
12
|
-
# Do not set this db to the same as development or production.
|
13
|
-
test: &TEST
|
1
|
+
production:
|
14
2
|
adapter: mysql
|
15
3
|
encoding: utf8
|
16
|
-
database:
|
4
|
+
database: ginst
|
17
5
|
pool: 5
|
18
6
|
username: root
|
19
|
-
password:
|
20
|
-
|
21
|
-
|
22
|
-
production:
|
7
|
+
password:
|
8
|
+
host: localhost
|
9
|
+
development:
|
23
10
|
adapter: mysql
|
24
11
|
encoding: utf8
|
25
12
|
database: ginst
|
26
13
|
pool: 5
|
27
14
|
username: root
|
28
15
|
password:
|
29
|
-
|
30
|
-
|
31
|
-
cucumber:
|
32
|
-
<<: *TEST
|
16
|
+
host: localhost
|
data/config/environment.rb
CHANGED
data/db/schema.rb
CHANGED
@@ -43,15 +43,15 @@ ActiveRecord::Schema.define(:version => 20091025165330) do
|
|
43
43
|
t.integer "project_id"
|
44
44
|
t.string "commit_sha1"
|
45
45
|
t.text "code"
|
46
|
-
t.integer "priority",
|
46
|
+
t.integer "priority", :default => 20
|
47
47
|
t.text "on_success"
|
48
48
|
t.text "on_failure"
|
49
|
-
t.boolean "system",
|
49
|
+
t.boolean "system", :default => false
|
50
50
|
t.datetime "started_at"
|
51
51
|
t.datetime "ended_at"
|
52
|
-
t.string "status",
|
52
|
+
t.string "status", :default => "prepared"
|
53
53
|
t.integer "pid"
|
54
|
-
t.text "output"
|
54
|
+
t.text "output", :limit => 2147483647
|
55
55
|
t.integer "exit_code"
|
56
56
|
t.datetime "created_at"
|
57
57
|
t.datetime "updated_at"
|
data/ginst.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{ginst}
|
8
|
-
s.version = "2009.11.
|
8
|
+
s.version = "2009.11.24"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Guillermo \303\201lvarez Fern\303\241ndez"]
|