summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormguetlein <martin.guetlein@gmail.com>2012-10-22 15:09:24 +0200
committermguetlein <martin.guetlein@gmail.com>2012-10-22 15:09:24 +0200
commit9cc49e7b735dd5343aa9a2ef8a5aa0a71d9cef17 (patch)
tree48fb5b02a4ae185574e5277a022dfa1049412822
parent45209f80a1d063f3d3b22131dfdaeb0cde3dcc0a (diff)
update task delete all
-rw-r--r--application.rb17
1 files changed, 11 insertions, 6 deletions
diff --git a/application.rb b/application.rb
index 5d89ada..9115008 100644
--- a/application.rb
+++ b/application.rb
@@ -290,14 +290,19 @@ end
# Delete all tasks
# @return [text/plain] Status message
delete '/?' do
+ i = 0
Task.all.each do |task|
- begin
- Process.kill(9,task.pid.to_i) unless task.pid.nil?
- task.delete
- response['Content-Type'] = 'text/plain'
- "All tasks deleted."
+ begin
+ unless task.hasStatus=="Running"
+ #Process.kill(9,task.pid.to_i) unless task.pid.nil?
+ task.delete
+ LOGGER.debug "deleted task #{task.id}"
+ i += 1
+ end
rescue
- "Cannot kill task with pid #{task.pid}"
+ LOGGER.debug "cannot kill task with pid #{task.pid}"
end
end
+ response['Content-Type'] = 'text/plain'
+ "#{i} tasks deleted."
end