meskyanichi/hirefire — Issue #40: Worker gets killed before destroy was commited
Author: mordaroso
Created: 2011-12-28 13:56:57+00:00
State: open

When I use a postgresql database with hirefire min_workers set to 0 there is always a Job in the database that was processed but still locked and in the database.

I found that the [following code](https://github.com/meskyanichi/hirefire/blob/develop/lib/hirefire/environment.rb#L41) is causing that behavior:

```ruby
after_destroy 'self.class.environment.fire'
```

When I comment out that line it works like expected. The worker [will get fired correctly after all jobs are done](https://github.com/meskyanichi/hirefire/blob/develop/lib/hirefire/workers/delayed_job/worker.rb#L62).

Is this after_destroy callback really needed? If yes, is it possible to exclude it when :local is used as environment?

My hirefire setup:

```ruby
require 'hirefire'
HireFire.configure do |config|
config.environment = :local
config.max_workers = 1
config.min_workers = 0
end
```