Skip to content

Instantly share code, notes, and snippets.

@stevendaniels
Created May 25, 2015 11:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevendaniels/9b62bcd8957e3b193cfe to your computer and use it in GitHub Desktop.
Save stevendaniels/9b62bcd8957e3b193cfe to your computer and use it in GitHub Desktop.
Sucker Punch Async Fails When Using Shotgun

Start the server

bundle exec shotgun

Make a request

curl 'http://localhost:9393/log'
curl 'http://localhost:9393/async-log'
class LogJob
include SuckerPunch::Job
workers 4
def perform(event)
File.open("log.#{rand(10_000)}.txt", 'a') { |f| f.puts event }
File.open('log.txt', 'a') { |f| f.puts event }
true
end
end
class MyApp < Sinatra::Base
get '/log' do
LogJob.new.perform(type: 'log', value: 'regular')
end
get '/async-log' do
LogJob.new.async.perform(type: 'log', value: 'async')
end
end
require 'bundler'
Bundler.require
require 'sucker_punch'
require 'sinatra'
require './app.rb'
run MyApp
source 'https://rubygems.org'
gem 'sucker_punch', '~> 1.5.0'
gem 'sinatra', '~> 1.4.6'
gem 'shotgun'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment