forked from resque/resque
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.rb
More file actions
38 lines (33 loc) · 1003 Bytes
/
app.rb
File metadata and controls
38 lines (33 loc) · 1003 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require 'sinatra/base'
require 'resque'
require 'job'
module Demo
class App < Sinatra::Base
get '/' do
info = Resque.info
out = "<html><head><title>Resque Demo</title></head><body>"
out << "<p>"
out << "There are #{info[:pending]} pending and "
out << "#{info[:processed]} processed jobs across #{info[:queues]} queues."
out << "</p>"
out << '<form method="POST">'
out << '<input type="submit" value="Create New Job"/>'
out << ' <a href="/resque/">View Resque</a>'
out << '</form>'
out << "<form action='/failing' method='POST''>"
out << '<input type="submit" value="Create Failing New Job"/>'
out << ' <a href="/resque/">View Resque</a>'
out << '</form>'
out << "</body></html>"
out
end
post '/' do
Resque.enqueue(Job, params)
redirect "/"
end
post '/failing' do
Resque.enqueue(FailingJob, params)
redirect "/"
end
end
end