Ruby on Rails
Tom Anderson

New! Spawn now works with nginx!

The spawn plugin makes it easy to “spawn” long-running blocks of code using either a forks or threads. Install the spawn plugin as follows:

The spawn plugin allows you to easily fork a background process within your app to handle long-running sections of code. Use it like this:

  spawn do
    # insert long-running code
  end

By default spawn detaches from the child process so you won’t have zombies. But, if you prefer, you can also wait for all of the children processes to finish:

  sids = []
  N.times do |i|
    sids[i] = spawn do
      do_something(i)
    end
  end
  wait(sids)

This plugin will either fork or thread the process depending on how you have it configured. Check the README for further documentation.

Email me your feedback at tom(at)squeat[dot]com.

I live in Denver where built these websites for fun:

And I get paid to work on this site: