Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save abhilashak/11b7be0f11665f211073e19307fca222 to your computer and use it in GitHub Desktop.
Save abhilashak/11b7be0f11665f211073e19307fca222 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