Skip to content

Commit

Permalink
thread state
Browse files Browse the repository at this point in the history
  • Loading branch information
jondot committed Sep 11, 2012
1 parent 3269e68 commit 3c5e075
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 12 deletions.
32 changes: 22 additions & 10 deletions README.md
Expand Up @@ -69,10 +69,10 @@ should be visible by the moment you write this code:


```ruby ```ruby
f = FrenzyBunnies::Context.new f = FrenzyBunnies::Context.new
f.run FeedWorker,FeedDownloader f.run FeedWorker, FeedDownloader
``` ```


Which will run your workers immediately. In the listing above, `f.run` accepts your worker _classes_, and will run your workers immediately.




## Web Dashboard ## Web Dashboard
Expand All @@ -94,7 +94,7 @@ context definitions


### Worker Configuration ### Worker Configuration


say `from_queue 'queue_name'` and pass any of these options: In your worker class, say `from_queue 'queue_name'` and pass any of these options:


```ruby ```ruby
:prefetch # default 10. number of messages to prefetch each time :prefetch # default 10. number of messages to prefetch each time
Expand All @@ -103,6 +103,16 @@ say `from_queue 'queue_name'` and pass any of these options:
:threads # default none. number of threads in the threadpool. leave empty to let the threadpool manage it. :threads # default none. number of threads in the threadpool. leave empty to let the threadpool manage it.
``` ```


Example:


```ruby
class FeedWorker
include FrenzyBunnies::Worker
from_queue 'new.feeds', :prefetch => 20, :threads => 13, :durable => true

...
```


### General Configuration ### General Configuration


Expand Down Expand Up @@ -132,14 +142,16 @@ semantics, the following is the AMQP wireup used within this library:


* Durable per configuration * Durable per configuration
* The exchange is created and named by default `frenzy_bunnies` * The exchange is created and named by default `frenzy_bunnies`
* Each worker is bound to an AMQP queue named `my_queue`_`environment` with the environment postfix appended automatically. * Each worker is bound to an AMQP queue named `my_queue_environment` with the environment postfix appended automatically.
* The routing key on the exchange is of the same name and bound to the queue. * The routing key on the exchange is of the same name and bound to the queue.


## Contributing # Contributing

Fork, implement, add tests, pull request, get my everlasting thanks and a respectable place here :).


# Copyright

Copyright (c) 2012 [Dotan Nahum](http://gplus.to/dotan) [@jondot](http://twitter.com/jondot). See MIT-LICENSE for further details.


1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Added some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request


3 changes: 2 additions & 1 deletion lib/frenzy_bunnies/health/providers/jvm.rb
Expand Up @@ -28,7 +28,8 @@ def report
if info && info.thread_name =~ @opts[:threadfilter] if info && info.thread_name =~ @opts[:threadfilter]
{ {
:name => info.thread_name, :name => info.thread_name,
:stack_trace => info.stack_trace.to_a.inject([]){|a,s| a<<s.to_s } :stack_trace => info.stack_trace.to_a.inject([]){|a,s| a<<s.to_s },
:state => info.thread_state.to_s
} }
else else
nil nil
Expand Down
24 changes: 23 additions & 1 deletion lib/frenzy_bunnies/web/public/index.html
Expand Up @@ -75,6 +75,25 @@
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
} }
.thread-name .state{
font-size:0.5em;
}
.state.NEW{
background-color: #ddd
}
.state.RUNNABLE{
background-color:#468847;
}
.state.BLOCKED{
background-color:#000;
}
.state.WAITING{
}
.state.TIMED_WAITING{
}
.state.TERMINATED{
background-color: red;
}
</style> </style>
<script id="tmpl-job" type="text/template"> <script id="tmpl-job" type="text/template">
<div class="job-detail"> <div class="job-detail">
Expand Down Expand Up @@ -126,7 +145,10 @@ <h3>Threads</h3>
<article id="threads"> <article id="threads">
<% _.each(threads, function(thread) { %> <% _.each(threads, function(thread) { %>
<div class="thread"> <div class="thread">
<div class="thread-name span4" title="<%= thread.name %>"><%= thread.name %></div> <div class="thread-name span4" title="<%= thread.name %>">
<%= thread.name %><br/>
<span class="label state <%=thread.state%>"><%= thread.state %></span>
</div>
<div class="thread-stack span8"> <div class="thread-stack span8">
<% _.each(thread.stack_trace, function(fragment, i) { %> <% _.each(thread.stack_trace, function(fragment, i) { %>
<% fragment_el = ellipsis(fragment, 80); %> <% fragment_el = ellipsis(fragment, 80); %>
Expand Down

0 comments on commit 3c5e075

Please sign in to comment.