Skip to content

Instantly share code, notes, and snippets.

@huyderman
Created April 21, 2015 10:45
Show Gist options
  • Save huyderman/6c50dfde4c5cc611b023 to your computer and use it in GitHub Desktop.
Save huyderman/6c50dfde4c5cc611b023 to your computer and use it in GitHub Desktop.
Fork with logger
require 'logger'
logger = Logger.new STDOUT
function = -> { logger.info "Something that takes a while..." }
# fork is not portable
if Process.respond_to?(:fork)
Process.detach fork(&function)
else
function
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment