brandonhilkert / sucker_punch

Sucker Punch is a Ruby asynchronous processing library using concurrent-ruby, heavily influenced by Sidekiq and girl_friday.
MIT License
2.65k stars 114 forks source link

Sucker Punch Async Fails When Using Shotgun #117

Closed stevendaniels closed 9 years ago

stevendaniels commented 9 years ago

When using the Shotgun gem, async.perform silently fails most of the time. It's most likely to work after just starting up the server. Using perform works as expected.

Here's a gist that reproduces the issue.

stevendaniels commented 9 years ago

I imagine this issue might be caused by shotgun's internals, which require fork(2). Is shotgun simply incompatible with sucker_punch / celluloid?

brandonhilkert commented 9 years ago

Should I be seeing something different:

[09:37:12] bhilkert [~/Dropbox/code/sp_test] (master) $ be shotgun
== Shotgun/WEBrick on http://127.0.0.1:9393/
[2015-05-25 09:37:16] INFO  WEBrick 1.3.1
[2015-05-25 09:37:16] INFO  ruby 2.2.0 (2014-12-25) [x86_64-darwin14]
[2015-05-25 09:37:16] INFO  WEBrick::HTTPServer#start: pid=6320 port=9393
127.0.0.1 - - [25/May/2015:09:37:19 -0400] "GET /async-log HTTP/1.1" 200 - 0.0171
stevendaniels commented 9 years ago

Check the output. The /async-log route should be creating a file and appending a file.

Try this before and after each curl

command (and run curl a few times).

   ll log*.txt | wc -l

On Mon, May 25, 2015 at 9:37 PM, Brandon Hilkert notifications@github.com wrote:

Should I be seeing something different:

[09:37:12] bhilkert [~/Dropbox/code/sp_test] (master) $ be shotgun
== Shotgun/WEBrick on http://127.0.0.1:9393/
[2015-05-25 09:37:16] INFO  WEBrick 1.3.1
[2015-05-25 09:37:16] INFO  ruby 2.2.0 (2014-12-25) [x86_64-darwin14]
[2015-05-25 09:37:16] INFO  WEBrick::HTTPServer#start: pid=6320 port=9393
127.0.0.1 - - [25/May/2015:09:37:19 -0400] "GET /async-log HTTP/1.1" 200 - 0.0171

Reply to this email directly or view it on GitHub: https://github.com/brandonhilkert/sucker_punch/issues/117#issuecomment-105234607

brandonhilkert commented 9 years ago

Gotcha. I tried adding a config/shotgun.rb file as the manpage suggests and adding:

require 'sucker_punch'

after_fork do
  puts "Clearing Sucker Punch queues..."
  SuckerPunch.clear_queues
end

The code runs, but there's not effect on the outcome. That's what's run in Rails automatically. I don't have much experience with Shotgun and its behavior. Might try opening an issue there.