ginst 2009.11.23 → 2009.11.24

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2009.11.23
1
+ 2009.11.24
@@ -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
- read = input.read_nonblock(99999999)
158
- logger read
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))
@@ -1,32 +1,16 @@
1
- development:
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: ginst_test
4
+ database: ginst
17
5
  pool: 5
18
6
  username: root
19
- password:
20
- socket: /tmp/mysql.sock
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
- socket: /tmp/mysql.sock
30
-
31
- cucumber:
32
- <<: *TEST
16
+ host: localhost
@@ -40,6 +40,8 @@ Rails::Initializer.run do |config|
40
40
  }
41
41
 
42
42
  # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
43
+ config.active_record.schema_format = :sql
44
+ config.action_mailer.delivery_method = :sendmail
43
45
  end
44
46
 
45
47
 
@@ -16,7 +16,7 @@ class CreateTasks < ActiveRecord::Migration
16
16
  t.datetime :started_at, :ended_at
17
17
  t.string :status, :default => 'prepared'
18
18
  t.integer :pid
19
- t.text :output
19
+ t.text :output, :limit => 10.megabytes
20
20
  t.integer :exit_code
21
21
 
22
22
  t.timestamps
@@ -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", :default => 20
46
+ t.integer "priority", :default => 20
47
47
  t.text "on_success"
48
48
  t.text "on_failure"
49
- t.boolean "system", :default => false
49
+ t.boolean "system", :default => false
50
50
  t.datetime "started_at"
51
51
  t.datetime "ended_at"
52
- t.string "status", :default => "prepared"
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"
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ginst}
8
- s.version = "2009.11.23"
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"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ginst
3
3
  version: !ruby/object:Gem::Version
4
- version: 2009.11.23
4
+ version: 2009.11.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Guillermo \xC3\x81lvarez Fern\xC3\xA1ndez"