Skip to content

Instantly share code, notes, and snippets.

@ChengLong
Last active April 19, 2021 20:59
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save ChengLong/7467977 to your computer and use it in GitHub Desktop.
Save ChengLong/7467977 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
@jubishop
Copy link

thanks for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment