resque_manager 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +21 -0
  3. data/README.markdown +417 -0
  4. data/Rakefile +41 -0
  5. data/app/assets/images/resque_manager/idle.png +0 -0
  6. data/app/assets/images/resque_manager/poll.png +0 -0
  7. data/app/assets/images/resque_manager/working.png +0 -0
  8. data/app/assets/javascripts/resque_manager/application.js +15 -0
  9. data/app/assets/javascripts/resque_manager/jquery-1.3.2.min.js +19 -0
  10. data/app/assets/javascripts/resque_manager/jquery.relatize_date.js +95 -0
  11. data/app/assets/javascripts/resque_manager/ranger.js +24 -0
  12. data/app/assets/stylesheets/resque_manager/application.css +14 -0
  13. data/app/assets/stylesheets/resque_manager/resque/resque.css +93 -0
  14. data/app/assets/stylesheets/resque_manager/resque/resque_reset.css +48 -0
  15. data/app/assets/stylesheets/resque_manager/resque_cleaner/cleaner.css +62 -0
  16. data/app/controllers/resque_manager/resque_controller.rb +313 -0
  17. data/app/helpers/resque_manager/application_helper.rb +4 -0
  18. data/app/helpers/resque_manager/resque_helper.rb +142 -0
  19. data/app/models/resque_manager/paginate.rb +54 -0
  20. data/app/views/layouts/resque_manager/application.html.erb +37 -0
  21. data/app/views/resque_manager/resque/_key.html.erb +17 -0
  22. data/app/views/resque_manager/resque/_limiter.html.erb +12 -0
  23. data/app/views/resque_manager/resque/_next_more.html.erb +10 -0
  24. data/app/views/resque_manager/resque/_paginate.html.erb +53 -0
  25. data/app/views/resque_manager/resque/_queues.html.erb +59 -0
  26. data/app/views/resque_manager/resque/_status_styles.erb +98 -0
  27. data/app/views/resque_manager/resque/_workers.html.erb +138 -0
  28. data/app/views/resque_manager/resque/_working.html.erb +69 -0
  29. data/app/views/resque_manager/resque/cleaner.html.erb +41 -0
  30. data/app/views/resque_manager/resque/cleaner_exec.html.erb +6 -0
  31. data/app/views/resque_manager/resque/cleaner_list.html.erb +172 -0
  32. data/app/views/resque_manager/resque/delayed.html.erb +35 -0
  33. data/app/views/resque_manager/resque/delayed_timestamp.html.erb +26 -0
  34. data/app/views/resque_manager/resque/error.erb +1 -0
  35. data/app/views/resque_manager/resque/overview.html.erb +4 -0
  36. data/app/views/resque_manager/resque/schedule.html.erb +96 -0
  37. data/app/views/resque_manager/resque/stats.html.erb +62 -0
  38. data/app/views/resque_manager/resque/status.html.erb +57 -0
  39. data/app/views/resque_manager/resque/statuses.html.erb +72 -0
  40. data/app/views/resque_manager/resque/workers.html.erb +1 -0
  41. data/config/routes.rb +38 -0
  42. data/config/sample_redis.yml +43 -0
  43. data/config/sample_resque_manager.yml +23 -0
  44. data/lib/resque_manager/engine.rb +9 -0
  45. data/lib/resque_manager/overrides/resque/failure/redis.rb +11 -0
  46. data/lib/resque_manager/overrides/resque/job.rb +69 -0
  47. data/lib/resque_manager/overrides/resque/resque.rb +8 -0
  48. data/lib/resque_manager/overrides/resque/worker.rb +291 -0
  49. data/lib/resque_manager/overrides/resque_scheduler/resque_scheduler.rb +58 -0
  50. data/lib/resque_manager/overrides/resque_status/chained_status.rb +46 -0
  51. data/lib/resque_manager/overrides/resque_status/hash.rb +12 -0
  52. data/lib/resque_manager/overrides/resque_status/status.rb +161 -0
  53. data/lib/resque_manager/recipes.rb +185 -0
  54. data/lib/resque_manager/version.rb +3 -0
  55. data/lib/resque_manager.rb +47 -0
  56. data/lib/tasks/failure.rake +8 -0
  57. data/lib/tasks/scheduler.rake +11 -0
  58. data/lib/tasks/worker.rake +129 -0
  59. data/test/dummy/README.rdoc +261 -0
  60. data/test/dummy/Rakefile +7 -0
  61. data/test/dummy/app/assets/javascripts/application.js +15 -0
  62. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  63. data/test/dummy/app/controllers/application_controller.rb +3 -0
  64. data/test/dummy/app/helpers/application_helper.rb +2 -0
  65. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  66. data/test/dummy/config/application.rb +65 -0
  67. data/test/dummy/config/boot.rb +10 -0
  68. data/test/dummy/config/environment.rb +5 -0
  69. data/test/dummy/config/environments/development.rb +37 -0
  70. data/test/dummy/config/environments/production.rb +67 -0
  71. data/test/dummy/config/environments/test.rb +37 -0
  72. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  73. data/test/dummy/config/initializers/inflections.rb +15 -0
  74. data/test/dummy/config/initializers/mime_types.rb +5 -0
  75. data/test/dummy/config/initializers/secret_token.rb +7 -0
  76. data/test/dummy/config/initializers/session_store.rb +8 -0
  77. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  78. data/test/dummy/config/locales/en.yml +5 -0
  79. data/test/dummy/config/routes.rb +4 -0
  80. data/test/dummy/config.ru +4 -0
  81. data/test/dummy/log/development.log +5045 -0
  82. data/test/dummy/public/404.html +26 -0
  83. data/test/dummy/public/422.html +26 -0
  84. data/test/dummy/public/500.html +25 -0
  85. data/test/dummy/public/favicon.ico +0 -0
  86. data/test/dummy/script/rails +6 -0
  87. data/test/dummy/tmp/cache/assets/C2A/A10/sprockets%2Fb2e622954654f415590723e9b882063e +0 -0
  88. data/test/dummy/tmp/cache/assets/C60/1D0/sprockets%2F8ed12e4193473760f95b973567a8c206 +0 -0
  89. data/test/dummy/tmp/cache/assets/CA1/970/sprockets%2Fc387148880e015d1eab0dc838b326022 +0 -0
  90. data/test/dummy/tmp/cache/assets/CAE/930/sprockets%2Fe227278d3c65d8aa1159da720263f771 +0 -0
  91. data/test/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
  92. data/test/dummy/tmp/cache/assets/CDC/E30/sprockets%2Fe1207380d69eeee3284e02636c26f24a +0 -0
  93. data/test/dummy/tmp/cache/assets/CF1/720/sprockets%2Fd91a5918f5aa43a43c8135a67c78e989 +0 -0
  94. data/test/dummy/tmp/cache/assets/D0E/820/sprockets%2F00c6cc9dc46bf64347b3775d7d15541b +0 -0
  95. data/test/dummy/tmp/cache/assets/D16/180/sprockets%2F73d6fa09352cb76ac81e1683e832b93f +0 -0
  96. data/test/dummy/tmp/cache/assets/D27/170/sprockets%2Fec164819553e2e5b28f1efc9bd970978 +0 -0
  97. data/test/dummy/tmp/cache/assets/D2B/DA0/sprockets%2F989465d3ea8575dd0b54981a9e8add38 +0 -0
  98. data/test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
  99. data/test/dummy/tmp/cache/assets/D37/1F0/sprockets%2F97119b908ebed2633edfd00ac90d9011 +0 -0
  100. data/test/dummy/tmp/cache/assets/D38/FB0/sprockets%2F74e5ba1cca7a1470d53c54fb60368b78 +0 -0
  101. data/test/dummy/tmp/cache/assets/D42/4E0/sprockets%2F0fa6e3c14356aa527d68a8d56fa37f28 +0 -0
  102. data/test/dummy/tmp/cache/assets/D43/C20/sprockets%2F1efd074fd1074b3dc88145b480ff961f +0 -0
  103. data/test/dummy/tmp/cache/assets/D46/CD0/sprockets%2F67f1ef70e7ede542318b8d55e25b16c3 +0 -0
  104. data/test/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
  105. data/test/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
  106. data/test/dummy/tmp/cache/assets/D68/080/sprockets%2Fa26f2ae225aa4b87c462d540c7cf43f9 +0 -0
  107. data/test/dummy/tmp/cache/assets/D9A/B20/sprockets%2F0eddc19d46318e2e286cc171ae4cc73e +0 -0
  108. data/test/dummy/tmp/cache/assets/DA4/900/sprockets%2F515bf984438c6ec4b8a515fcc13baf8e +0 -0
  109. data/test/dummy/tmp/cache/assets/DBD/070/sprockets%2F60ffef45ddefd5c7746d17977fff0717 +0 -0
  110. data/test/dummy/tmp/cache/assets/DD7/AC0/sprockets%2Fc7c983c5c607dbfdb726eecc36146ca9 +0 -0
  111. data/test/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
  112. data/test/dummy/tmp/cache/assets/DF5/480/sprockets%2Fea4f3c726fc1046cad1ad243faf84e7d +0 -0
  113. data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
  114. data/test/dummy/tmp/cache/assets/E2B/7A0/sprockets%2Fd44ef07be0aa6d5b5dea4d37d7f72b4f +0 -0
  115. data/test/functional/resque_manager/resque_controller_test.rb +9 -0
  116. data/test/integration/navigation_test.rb +10 -0
  117. data/test/resque_manager_test.rb +7 -0
  118. data/test/test_helper.rb +15 -0
  119. data/test/unit/helpers/resque_manager/resque_helper_test.rb +6 -0
  120. metadata +307 -0
@@ -0,0 +1,96 @@
1
+
2
+ <div id="schedule">
3
+ <h1>Schedule</h1>
4
+
5
+ <p class='intro'>
6
+ The list below contains all scheduled jobs. Click &quot;Queue now&quot; to queue
7
+ a job immediately.
8
+ </p>
9
+
10
+ <table>
11
+ <tr>
12
+ <th></th>
13
+ <th>Name</th>
14
+ <th>IP</th>
15
+ <th>Description</th>
16
+ <th>Cron</th>
17
+ <th>Class</th>
18
+ <th>Arguments</th>
19
+ <th></th>
20
+ </tr>
21
+ <% Resque.schedule.each do |name,config| %>
22
+ <tr>
23
+ <td>
24
+ <%= button_to "Queue now", {:controller=>'resque', :action=> 'schedule_requeue', :job_name => name}, :method => :post %>
25
+ </td>
26
+ <td><%= h name %></td>
27
+ <td><%= h config['ip'] %></td>
28
+ <td><%= h config['description'] %></td>
29
+ <td style="white-space:nowrap"><%= h config['cron'] %></td>
30
+ <td><%= h config['class'] %></td>
31
+ <td><%= h config['args'].inspect %></td>
32
+ <td><%= button_to "Remove", {:controller=>'resque', :action=> 'remove_from_schedule', :job_name => name, :ip => config['ip']}, :method => :post %></td>
33
+ </tr>
34
+ <%end%>
35
+ </table>
36
+
37
+ <h1>Add Job to Schedule</h1>
38
+ <div id='flash' class="flash">
39
+ <%flash_message = flash_helper%>
40
+ <% unless flash_message.blank? -%>
41
+ <p>
42
+ <%= flash_message %>
43
+ </p>
44
+ <%= javascript_tag "$('flash').show();" %>
45
+ <% end %>
46
+ </div>
47
+ <%= form_tag '/resque/add_scheduled_job' do -%>
48
+ <table>
49
+ <tr>
50
+ <th>Name</th>
51
+ <th>IP</th>
52
+ <th>Description</th>
53
+ <th>Cron</th>
54
+ <th>Class</th>
55
+ <th>Arguments</th>
56
+ <th></th>
57
+ </tr>
58
+ <tr>
59
+ <td><%= text_field_tag :name %></td>
60
+ <td><%= text_field_tag :ip %></td>
61
+ <td><%= text_field_tag :description %></td>
62
+ <td style="white-space:nowrap"><%= text_field_tag :cron %></td>
63
+ <td><%= text_field_tag :class %></td>
64
+ <td><%= text_area_tag :args, nil, :rows => 1, :cols => 40%></td>
65
+ <td>
66
+ <%= submit_tag 'Add Job', :id => 'add_job' %>
67
+ </td>
68
+ </tr>
69
+ </table>
70
+ <% end -%>
71
+
72
+ <h1>Farm Status</h1>
73
+
74
+ <table>
75
+ <tr>
76
+ <th>IP</th>
77
+ <th>Status</th>
78
+ <th></th>
79
+ </tr>
80
+ <%@farm_status.each do |ip,status| -%>
81
+ <tr>
82
+ <td>
83
+ <%= ip %>
84
+ </td>
85
+ <td><%= status %></td>
86
+ <td>
87
+ <% if status == 'Running' -%>
88
+ <%= button_to "Stop Scheduler", {:controller=>'resque', :action=> 'stop_scheduler', :ip => ip}, :method => :post %>
89
+ <% else -%>
90
+ <%= button_to "Start Scheduler", {:controller=>'resque', :action=> 'start_scheduler', :ip => ip}, :method => :post %>
91
+ <% end -%>
92
+ </td>
93
+ </tr>
94
+ <% end -%>
95
+ </table>
96
+ </div>
@@ -0,0 +1,62 @@
1
+ <% @subtabs = %w( resque redis keys ) %>
2
+
3
+ <% if params[:key] %>
4
+
5
+ <%= render(:partial => 'key') %>
6
+
7
+ <% elsif params[:id] == "resque" %>
8
+
9
+ <h1><%= resque %></h1>
10
+ <table class='stats'>
11
+ <% for key, value in resque.info.to_a.sort_by { |i| i[0].to_s } %>
12
+ <tr>
13
+ <th>
14
+ <%= key %>
15
+ </th>
16
+ <td>
17
+ <%= value %>
18
+ </td>
19
+ </tr>
20
+ <% end %>
21
+ </table>
22
+
23
+ <% elsif params[:id] == 'redis' %>
24
+
25
+ <h1><%= resque.redis_id %></h1>
26
+ <table class='stats'>
27
+ <% for key, value in resque.redis.info.to_a.sort_by { |i| i[0].to_s } %>
28
+ <tr>
29
+ <th>
30
+ <%= key %>
31
+ </th>
32
+ <td>
33
+ <%= value %>
34
+ </td>
35
+ </tr>
36
+ <% end %>
37
+ </table>
38
+
39
+ <% elsif params[:id] == 'keys' %>
40
+
41
+ <h1>Keys owned by <%= resque %></h1>
42
+ <p class='sub'>(All keys are actually prefixed with "resque:")</p>
43
+ <table class='stats'>
44
+ <tr>
45
+ <th>key</th>
46
+ <th>type</th>
47
+ <th>size</th>
48
+ </tr>
49
+ <% for key in resque.keys.sort %>
50
+ <tr>
51
+ <th>
52
+ <%= link_to(key, "/resque/stats/keys?key=#{key}") %>
53
+ </th>
54
+ <td><%= resque.redis.type key %></td>
55
+ <td><%= redis_get_size key %></td>
56
+ </tr>
57
+ <% end %>
58
+ </table>
59
+
60
+ <% else %>
61
+
62
+ <% end %>
@@ -0,0 +1,57 @@
1
+ <%= render(:partial => 'status_styles') %>
2
+
3
+ <h1 class='wi'>Statuses: <%= @status.uuid %>/<%= @status.name %></h1>
4
+ <p class='intro'>Viewing a specific job created with JobWithStatus. <%= link_to('Return to the list of statuses', :action => "statuses") %></p>
5
+
6
+ <div class="status-holder" rel="<%= @status.status %>" id="status_<%= @status.uuid %>">
7
+ <div class="status-progress">
8
+ <div class="status-progress-bar status-<%= @status.status %>" style="width: <%= @status.pct_complete %>%;"></div>
9
+ <p><%= @status.pct_complete %>%</p>
10
+ </div>
11
+ <div class="status-message"><%= @status.message %></div>
12
+ <div class="status-time"><%= @status.time? ? format_time(Time.zone.parse(@status.time.to_s)) : 'Not started' %></div>
13
+ </div>
14
+
15
+ <script type="text/javascript" charset="utf-8">
16
+ jQuery(function($) {
17
+
18
+ // itterate over the holders
19
+ $('.status-holder').each(function() {
20
+ checkStatus($(this));
21
+ });
22
+
23
+ function checkStatus($status) {
24
+ var status_id = $status.attr('id').replace('status_', '');
25
+ $.getJSON('<%= url(:statuses) %>/' + status_id + '.js', function(json) {
26
+ if (json) {
27
+ var pct = "0%";
28
+ if (json.pct_complete) {
29
+ var pct = json.pct_complete + "%";
30
+ }
31
+ $status.find('.status-progress-bar').animate({width: pct});
32
+ $status.find('.status-progress p').text(pct)
33
+ if (json.message) {
34
+ $status.find('.status-message').html(json.message)
35
+ }
36
+ if (json.status) {
37
+ $status
38
+ .attr('rel', json.status)
39
+ .find('.status-progress-bar')
40
+ .attr('class', '')
41
+ .addClass('status-progress-bar status-' + json.status);
42
+ }
43
+ if (json.time) {
44
+ $status.find('.status-time').text(new Date(json.time * 1000).toString())
45
+ }
46
+ };
47
+ var status = $status.attr('rel');
48
+ if (status == 'working' || status == 'queued' || status == "") {
49
+ setTimeout(function() {
50
+ checkStatus($status)
51
+ }, 1500);
52
+ }
53
+ });
54
+ };
55
+
56
+ });
57
+ </script>
@@ -0,0 +1,72 @@
1
+ <%= render(:partial => 'status_styles') %>
2
+
3
+ <h1 class='wi'>Statuses</h1>
4
+ <%unless @statuses.empty?%>
5
+ <form method="POST" action="clear_statuses" class='clear-failed'>
6
+ <input type='submit' name='' value='Clear Statuses' />
7
+ </form>
8
+ <%end%>
9
+ <p class='intro'>These are recent jobs created with the JobWithStatus class</p>
10
+ <p class='sub'>Showing <%=@start%> to <%= @start + 20 %> of <b><%= @size %></b> statuses</p>
11
+ <table>
12
+ <tr>
13
+ <th>ID</th>
14
+ <th style="width:40%">Name</th>
15
+ <th>Status</th>
16
+ <th>Last Updated</th>
17
+ <th class="progress">% Complete</th>
18
+ <th>Message</th>
19
+ <th>Kill</th>
20
+ </tr>
21
+ <% unless @statuses.empty? %>
22
+ <% @statuses.each do |status| %>
23
+ <tr>
24
+ <td><%= link_to(status.uuid, {:action => 'status', :id => status.uuid}) %></td>
25
+ <td><%= status.name %></td>
26
+ <td class="status status-<%= status.status %>"><%= status.status %></td>
27
+ <td class="time"><%= format_time(Time.zone.parse(status.time.to_s)) %></td>
28
+ <td class="progress">
29
+ <div class="progress-bar" style="width:<%= status.pct_complete %>%">&nbsp;</div>
30
+ <div class="progress-pct"><%= status.pct_complete ? "#{status.pct_complete}%" : '' %></div>
31
+ </td>
32
+ <td><%= status.message.to_s.html_safe %></td>
33
+ <td><% if status.killable? %><%= button_to('Kill', {:action => :kill, :id => status.uuid}, :class => 'kill') %><% end %></td>
34
+ </tr>
35
+ <% end %>
36
+ <% else %>
37
+ <tr>
38
+ <td colspan="7" class='no-data'>No Statuses right now...</td>
39
+ </tr>
40
+ <% end %>
41
+ </table>
42
+
43
+ <% unless @statuses.empty? %>
44
+ <%= render(:partial => 'next_more', :locals => {:start => @start, :size => @size}) %>
45
+ <% end %>
46
+
47
+ <%= status_poll(@start) %>
48
+
49
+ <script type="text/javascript" charset="utf-8">
50
+ jQuery(function($) {
51
+
52
+ $('a.kill').click(function(e) {
53
+ e.preventDefault();
54
+ var $link = $(this),
55
+ url = $link.attr('href'),
56
+ confirmed = confirm("Are you sure you want to kill this job? There is only do or do not. There is no undo.");
57
+ if (confirmed) {
58
+ $link.animate({opacity: 0.5});
59
+ $.ajax({
60
+ url: url,
61
+ type: 'post',
62
+ success: function() {
63
+ $link.remove();
64
+ }
65
+ });
66
+ } else {
67
+ return false
68
+ }
69
+ });
70
+
71
+ });
72
+ </script>
@@ -0,0 +1 @@
1
+ <%= render(:partial => 'workers') %>
data/config/routes.rb ADDED
@@ -0,0 +1,38 @@
1
+ ResqueManager::Engine.routes.draw do
2
+
3
+ root to: "resque#overview"
4
+
5
+ resource 'resque', only: [:index], path: '', controller: 'resque' do
6
+ member do
7
+ get :overview
8
+ get :workers
9
+ get :working
10
+ get :queues
11
+ get :poll
12
+ get :stats
13
+ get :status_poll
14
+ post :remove_job
15
+ post :stop_worker
16
+ post :pause_worker
17
+ post :continue_worker
18
+ post :restart_worker
19
+ post :start_worker
20
+ get :status_poll
21
+ get :schedule
22
+ post :schedule_requeue
23
+ post :add_scheduled_job
24
+ post :remove_from_schedule
25
+ post :start_scheduler
26
+ post :stop_scheduler
27
+ get :statuses
28
+ post :clear_statuses
29
+ get :status
30
+ post :kill
31
+ get :cleaner
32
+ get :cleaner_list
33
+ post :cleaner_exec
34
+ post :cleaner_dump
35
+ post :cleaner_stale
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,43 @@
1
+ development: &default_development
2
+ :host: 127.0.0.1
3
+ :thread_safe: true
4
+
5
+ development_resque:
6
+ <<: *default_development
7
+ :db: 1
8
+
9
+ test: &default_test
10
+ :host: 127.0.0.1
11
+ :db: <%= 10 + ENV['TEST_ENV_NUMBER'].to_i %>
12
+ :thread_safe: true
13
+
14
+ test_resque:
15
+ <<: *default_test
16
+ :db: <%= 40 + ENV['TEST_ENV_NUMBER'].to_i %>
17
+
18
+ release: &default_release
19
+ :host: release1
20
+ :thread_safe: true
21
+
22
+ release_resque:
23
+ <<: *default_release
24
+ :db: 1
25
+
26
+ hotfix: &default_hotfix
27
+ :host: hotfix1
28
+ :thread_safe: true
29
+
30
+ hotfix_resque:
31
+ <<: *default_hotfix
32
+ :db: 1
33
+
34
+ production:
35
+ :host: redis
36
+ :pool_size: 30
37
+ :db: 3
38
+ :thread_safe: true
39
+
40
+ production_resque:
41
+ :host: resque
42
+ :thread_safe: true
43
+ :port: 6380
@@ -0,0 +1,23 @@
1
+ development: &default
2
+ key_expiration: 604800 #<%= 1.week %>
3
+ inline: true
4
+ applications:
5
+ application1: /Users/ktyll/rails_sites/git/application1
6
+ application2: /Users/ktyll/rails_sites/git/application2
7
+
8
+ test:
9
+ <<: *default
10
+
11
+ release:
12
+ <<: *default
13
+ inline: false
14
+ applications:
15
+ application1: /var/www/rails/application1/current
16
+ application2: /var/www/rails/application2/current
17
+
18
+ production:
19
+ <<: *default
20
+ inline: false
21
+ applications:
22
+ application1: /var/www/rails/application1/current
23
+ application2: /var/www/rails/application2/current
@@ -0,0 +1,9 @@
1
+ module ResqueManager
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace ResqueManager
4
+
5
+ initializer "resque_manager.assets.precompile" do |app|
6
+ app.config.assets.precompile += %w(resque_manager/application.css resque_manager/application.js)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ require 'resque/failure/redis'
2
+ module Resque
3
+ module Failure
4
+ class Redis
5
+ def filter_backtrace(backtrace)
6
+ index = backtrace.index { |item| item.include?('/lib/resque_manager/overrides/resque/job.rb') }
7
+ backtrace.first(index.to_i)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,69 @@
1
+ module Resque
2
+ class Job
3
+ # Attempts to perform the work represented by this job instance.
4
+ # Calls #perform on the class given in the payload with the
5
+ # arguments given in the payload.
6
+ # A block is sent so a message can be yielded back to be set in the worker.
7
+ def perform
8
+ job = payload_class
9
+ job_args = args || []
10
+ job_was_performed = false
11
+
12
+ begin
13
+ # Execute before_perform hook. Abort the job gracefully if
14
+ # Resque::DontPerform is raised.
15
+ begin
16
+ before_hooks.each do |hook|
17
+ job.send(hook, *job_args)
18
+ end
19
+ rescue DontPerform
20
+ return false
21
+ end
22
+
23
+ # Execute the job. Do it in an around_perform hook if available.
24
+ if around_hooks.empty?
25
+ job.perform(*job_args) do |status|
26
+ self.worker
27
+ end
28
+ job_was_performed = true
29
+ else
30
+ # We want to nest all around_perform plugins, with the last one
31
+ # finally calling perform
32
+ stack = around_hooks.reverse.inject(nil) do |last_hook, hook|
33
+ if last_hook
34
+ lambda do
35
+ job.send(hook, *job_args) { last_hook.call }
36
+ end
37
+ else
38
+ lambda do
39
+ job.send(hook, *job_args) do
40
+ result = job.perform(*job_args) do |status|
41
+ self.worker
42
+ end
43
+ job_was_performed = true
44
+ result
45
+ end
46
+ end
47
+ end
48
+ end
49
+ stack.call
50
+ end
51
+
52
+ # Execute after_perform hook
53
+ after_hooks.each do |hook|
54
+ job.send(hook, *job_args)
55
+ end
56
+
57
+ # Return true if the job was performed
58
+ return job_was_performed
59
+
60
+ # If an exception occurs during the job execution, look for an
61
+ # on_failure hook then re-raise.
62
+ rescue Object => e
63
+ failure_hooks.each { |hook| job.send(hook, e, *job_args) }
64
+ raise e
65
+ end
66
+ end
67
+
68
+ end
69
+ end
@@ -0,0 +1,8 @@
1
+ module Resque
2
+ def self.throttle(queue, limit = 10000, sleep_for = 60)
3
+ loop do
4
+ break if Resque.size(queue.to_s) < limit
5
+ sleep sleep_for
6
+ end
7
+ end
8
+ end