Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The fork does make a copy of your entire process, and, depending on exactly how you are hooked up to the application server, a copy of that as well. As noted in the other discussion this is done with <em>copy-on-write</em> so it's tolerable. Unix is built around fork(2), after all, so it has to manage it fairly fast. Note that any partially buffered I/O, open files, and lots of other stuff are also copied, as well as the state of the program that is spring-loaded to write them out, which would be incorrect.</p> <p>I have a few thoughts:</p> <ul> <li>Are you using Action Mailer? It seems like email would be easily done with AM or by <code>Process.popen</code> of something. (Popen will do a fork, but it is immediately followed by an exec.)</li> <li>immediately get rid of all that state by executing <code>Process.exec</code> of another ruby interpreter plus your functionality. If there is too much state to transfer or you really need to use those duplicated file descriptors, you might do something like <code>IO#popen</code> instead so you can send the subprocess work to do. The system will share the pages containing the text of the Ruby interpreter of the subprocess with the parent automatically.</li> <li>in addition to the above, you might want to consider the use of the <code>daemons</code> gem. While your rails process is already a daemon, using the gem might make it easier to keep one background task running as a batch job server, and make it easy to start, monitor, restart if it bombs, and shut down when you do...</li> <li>if you do exit from a <code>fork(2)</code>ed subprocess, use <code>exit!</code> instead of <code>exit</code></li> <li>having a message queue and a daemon already set up, like you do, kinda sounds like a good solution to me :-)</li> </ul>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload