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' |