Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Stop running background tasks on panel stop.

  • Loading branch information...
commit 274df6ba6c1a8cf48004f7941fa679c18b2208ad 1 parent 303434d
@sibprogrammer authored
View
8 app/models/background_job.rb
@@ -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
View
2  app/views/admin/tasks/list.html.erb
@@ -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';
}
View
1  app/views/iphone/tasks/list.erb
@@ -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
1  script/owp
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.