Forum: Ruby on Rails starting a non blocking child process

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Jatinder S. (Guest)
on 2006-06-05 07:52
(Received via mailing list)
>From a ruby program I would like to start another process which should
continue to run even after the parent process dies.
Is there any way I could achive this?

>From the child process I want to start an instance of SCGI server which
should continue to run even if the parent process dies.



Thanks in Advance,
Jatinder
Jatinder S. (Guest)
on 2006-06-05 12:19
(Received via mailing list)
After spending a while with google, I found following...

1. Fork is not present on Windows; will have to use Win32-process module
for
enabling fork.
2. Threads are the way to achiveve platform independence in such cases.
3. Daemons module(support for POSIX systems) can be used for creating
daemons.
    http://rubyforge.org/projects/daemons/.

I tried using threads from one of the methods of a controller of an RoR
application; I have following method in my controller which gets called
when
a link is clicked in one of the rhtml pages.

def servst
 threads =[]
 threads<< Thread.new {
 system 'cd C:\InstantRails\rails_apps\xyz &
C:\InstantRails\ruby\bin\ruby
C:\InstantRails\ruby\bin\scgi_service'
 }

  threads.each { |t| t.join}
 end
when this method is called(on click of a link in an rhtml page), I.E.
progress bar goes on showing some progress, but never completes.
Note: The server I intend to start does gets started; but the current
session from where the server was started gets hung.
I need a way to start the server and continue traversing various links
in
the same session.

Thanks
Jatinder
This topic is locked and can not be replied to.