Starting a system command and letting it be?

I'm writing a web service that accepts a call to initiate a few
self-contained scripts on a RHEL4 webserver. Being new to Ruby, I
can't seem to find any documentation on how I could kick off the
scripts without having the parent script wait on them to complete.
Obviously, I don't need arguments our output back from the scripts, so
all I'm concerned with is that they start and the parent can end
without killing them.

What's the best way to do this?

You could just use ruby threads?

Farrel

···

On 10/11/06, darenbell@gmail.com <darenbell@gmail.com> wrote:

I'm writing a web service that accepts a call to initiate a few
self-contained scripts on a RHEL4 webserver. Being new to Ruby, I
can't seem to find any documentation on how I could kick off the
scripts without having the parent script wait on them to complete.
Obviously, I don't need arguments our output back from the scripts, so
all I'm concerned with is that they start and the parent can end
without killing them.

What's the best way to do this?

by far the simplest is

   system "in_the_background &"

-a

···

On Fri, 10 Nov 2006, darenbell@gmail.com wrote:

I'm writing a web service that accepts a call to initiate a few
self-contained scripts on a RHEL4 webserver. Being new to Ruby, I
can't seem to find any documentation on how I could kick off the
scripts without having the parent script wait on them to complete.
Obviously, I don't need arguments our output back from the scripts, so
all I'm concerned with is that they start and the parent can end
without killing them.

What's the best way to do this?

--
my religion is very simple. my religion is kindness. -- the dalai lama

What's the best way to do this?

Have a look at BackgrounDRb, it's a rails plugin designed specifically
for this type of thing: kicking off long-running tasks without making
rails wait for it to finish. You'll still probably use system() for
running your script, but if you use one of the popens (2, 3, or 4) you
can get stdout and feed that back to the rails app incrementally.

Here's an introductory article: Introduction to BackgrounDRb - InfoQ
and the rubyforge page: http://rubyforge.org/projects/backgroundrb/

OK, that was too obvious. :slight_smile:

Works fine in a local script, but my web service client is just sitting
there waiting. Guess that's the problem.

···

On Nov 10, 8:43 am, ara.t.how...@noaa.gov wrote:

On Fri, 10 Nov 2006, darenb...@gmail.com wrote:
> I'm writing a web service that accepts a call to initiate a few
> self-contained scripts on a RHEL4 webserver. Being new to Ruby, I
> can't seem to find any documentation on how I could kick off the
> scripts without having the parent script wait on them to complete.
> Obviously, I don't need arguments our output back from the scripts, so
> all I'm concerned with is that they start and the parent can end
> without killing them.

> What's the best way to do this?by far the simplest is

   system "in_the_background &"

-a
--
my religion is very simple. my religion is kindness. -- the dalai lama

OK, that was too obvious. :slight_smile:

Works fine in a local script, but my web service client is just sitting
there waiting. Guess that's the problem.

···

On Nov 10, 8:43 am, ara.t.how...@noaa.gov wrote:

On Fri, 10 Nov 2006, darenb...@gmail.com wrote:
> I'm writing a web service that accepts a call to initiate a few
> self-contained scripts on a RHEL4 webserver. Being new to Ruby, I
> can't seem to find any documentation on how I could kick off the
> scripts without having the parent script wait on them to complete.
> Obviously, I don't need arguments our output back from the scripts, so
> all I'm concerned with is that they start and the parent can end
> without killing them.

> What's the best way to do this?by far the simplest is

   system "in_the_background &"

-a
--
my religion is very simple. my religion is kindness. -- the dalai lama

Farrel Lifson wrote:

···

On 10/11/06, darenbell@gmail.com <darenbell@gmail.com> wrote:

I'm writing a web service that accepts a call to initiate a few
self-contained scripts on a RHEL4 webserver. Being new to Ruby, I
can't seem to find any documentation on how I could kick off the
scripts without having the parent script wait on them to complete.
Obviously, I don't need arguments our output back from the scripts, so
all I'm concerned with is that they start and the parent can end
without killing them.

What's the best way to do this?

You could just use ruby threads?

If the scripts do anything with standard input, they could hijack the
Ruby script's from the thread. Use popen, or the open('|some-script')
form instead of system?

David Vallner

perhaps, but probably caused by another issue. there's no reason why that
should not work from your web-server. if the client is hanging you've got
something else going on... show us the simplified code?

-a

···

On Sat, 11 Nov 2006, darenbell@gmail.com wrote:

OK, that was too obvious. :slight_smile:

Works fine in a local script, but my web service client is just sitting
there waiting. Guess that's the problem.

--
my religion is very simple. my religion is kindness. -- the dalai lama

Sorry for not responding sooner, but I was out of my office since my
last response. David's solution worked perfectly. Thanks for the help
everyone.

···

On Nov 11, 7:06 am, David Vallner <d...@vallner.net> wrote:

Farrel Lifson wrote:
> On 10/11/06, darenb...@gmail.com <darenb...@gmail.com> wrote:
>> I'm writing a web service that accepts a call to initiate a few
>> self-contained scripts on a RHEL4 webserver. Being new to Ruby, I
>> can't seem to find any documentation on how I could kick off the
>> scripts without having the parent script wait on them to complete.
>> Obviously, I don't need arguments our output back from the scripts, so
>> all I'm concerned with is that they start and the parent can end
>> without killing them.

>> What's the best way to do this?

> You could just use ruby threads?If the scripts do anything with standard input, they could hijack the
Ruby script's from the thread. Use popen, or the open('|some-script')
form instead of system?

David Vallner

signature.asc
1KDownload