Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jubishop/f0eadfcf566150088244acfdd2947b87 to your computer and use it in GitHub Desktop.
Save jubishop/f0eadfcf566150088244acfdd2947b87 to your computer and use it in GitHub Desktop.
Run Background Process in Sinatra
require 'sinatra'
get '/long_process' do
child_pid = Process.fork do
# hard work is done here...
sleep 10
Process.exit
end
Process.detach child_pid # No zombie process
'Doing hard work in the background...'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment