Permalink
Browse files

Stop running background tasks on panel stop.

  • Loading branch information...
sibprogrammer committed Mar 17, 2012
1 parent 303434d commit 274df6ba6c1a8cf48004f7941fa679c18b2208ad
Showing with 12 additions and 0 deletions.
  1. +8 −0 app/models/background_job.rb
  2. +2 −0 app/views/admin/tasks/list.html.erb
  3. +1 −0 app/views/iphone/tasks/list.erb
  4. +1 −0 script/owp
@@ -2,6 +2,7 @@ class BackgroundJob < ActiveRecord::Base
FINISHED = 0
RUNNING = 1
+ FAILED = 2
def self.create(description, params = {})
if BackgroundJob.count > AppConfig.tasks.max_records
@@ -23,4 +24,11 @@ def t_description(locale = I18n.locale)
I18n.t("admin.tasks." + self.description, params)
end
+ def self.stop_running
+ find(:all, :conditions => ['status = ?', RUNNING]).each do |job|
+ job.status = FAILED
+ job.save
+ end
+ end
+
end
@@ -36,6 +36,8 @@ Ext.onReady(function() {
renderer: function(value) {
if (1 == value) {
var image = 'spinner.gif';
+ } else if (2 == value) {
+ var image = 'exclamation.png';
} else {
var image = 'accept.png';
}
@@ -5,6 +5,7 @@
<%
icon = 'accept.png'
icon = 'spinner.gif' if 1 == task.status
+ icon = 'exclamation.png' if 2 == task.status
%>
<%= image_tag icon, :class => 'inline' %>
#<%= h(task.id) %>
View
@@ -127,6 +127,7 @@ stop() {
echo_fail "Unable to stop web server."
else
echo_ok "Web server was stopped."
+ ruby $INSTALL_DIR/script/runner -e production "BackgroundJob.stop_running" > /dev/null 2>&1
fi
fi

0 comments on commit 274df6b

Please sign in to comment.