[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Spawning daemon processes

Thiago Arrais

8/31/2006 5:07:00 PM

I am trying to start and stop a daemon process from inside my Ruby
program. At first I tried using fork to do the job, as in

server_pid = fork do
system 'runserver'
end

Then I could use the returned PID to send the process a signal by
using Process.kill. But, as far as i know, fork unfortunately doesn't
work on Windows. I read somewhere I should be using Thread.new if I
want the code to be platform independent, like this:

thread = Thread.new do
system 'runserver'
end

The question is: how do I kill the subprocess when using threads? I
tried thread.kill and thread.stop, but they won't do the trick. When
using threads, what I get are a lot of orphan processes after the
initial Ruby program finishes.

Is there any idiomatic way of doing that in Ruby that is platform independent?

Cheers,

Thiago Arrais
--
Mergulhando no Caos - http://thiagoarrais.bl...
Pensamentos, idéias e devaneios sobre desenvolvimento de software e
tecnologia em geral

10 Answers

khaines

8/31/2006 5:42:00 PM

0

Garance A Drosehn

9/1/2006 1:34:00 AM

0

On 8/31/06, Thiago Arrais <thiago.arrais@gmail.com> wrote:
> I am trying to start and stop a daemon process from inside my Ruby
> program. At first I tried using fork to do the job, as in
>
> server_pid = fork do
> system 'runserver'
> end
>
> Then I could use the returned PID to send the process a signal by
> using Process.kill.

For unix, you might want to check out the rubygem called 'daemons'.
If you are not setup with rubygems, you could also download it from:

http://rubyforge.org/project...

If what you are writing is meant to be a standard unix daemon, which
implies a number of things about how it should behave, then this
daemons package will handle many of the details that you might
not be aware of.

I only use the daemons package on unix, and I suspect that it does
not work on Windows.

> But, as far as i know, fork unfortunately doesn't work on Windows.

My guess is that you need to write your script to do one set of things
under Unix, and something else when it is run under WIndows.
But maybe someone else will have a useful solution for you.

--
Garance Alistair Drosehn = drosihn@gmail.com
Senior Systems Programmer
Rensselaer Polytechnic Institute; Troy, NY; USA

M. Edward (Ed) Borasky

9/1/2006 4:01:00 AM

0

Thiago Arrais wrote:
> [snip]
> Thiago Arrais

Be careful ... we don't want to have Ruby known as "daemon spawn", do we?

<ducking>

Thiago Arrais

9/1/2006 8:23:00 PM

0

Kirk,

Thanks for pointer.

After some talking to Daniel, I could actually use his win32-process
library. It had a little bug that prevented it from being used under
Win2k, but he promptly fixed it.

Cheers,

Thiago Arrais

Yoorghis

8/18/2012 7:20:00 PM

0

On Sat, 18 Aug 2012 11:46:53 -0700, Klaus Schadenfreude
<klausschadenfreude@yahoo.com> wrote:

>>Yoorghis@Jurgis.net wrote in talk.politics.guns :
>
>>On Sat, 18 Aug 2012 06:42:56 -0700, Klaus Schadenfreude
>><klausschadenfreude@yahoo.com> wrote:
>>
>>>>deep <deep@dudu.org> wrote in talk.politics.guns :
>>>
>>>> Republicans deregulated
>>>>the financial industry,
>>>
>>>
>>>LOL
>>>
>>>You really ARE ignorant, aren't you?
>>
>>No, he's not
>>
>>From 1994 on---Repubicans[..]
>
>LOL There's TWO of you!

But you can't deny the truth of what I said, can you?

George Plimpton

8/20/2012 3:52:00 PM

0

On 8/20/2012 8:47 AM, Yoorghis@Jurgis.net wrote:
> On Mon, 20 Aug 2012 06:26:26 -0700, Klaus Schadenfreude
> <klausschadenfreude@yahoo.com> wrote:
>
>>> Yoorghis@Jurgis.net wrote in talk.politics.guns :
>>
>>> On Sun, 19 Aug 2012 17:00:27 -0700, Klaus Schadenfreude
>>> <klausschadenfreude@yahoo.com> wrote:
>>>
>>>>> I admit nothing that you idiots are inferring
>>>>
>>>> Um, yeah, you did.
>>>>
>>>> You admitted that Democrats causes 15% of the problems.
>>>>
>>>> Rather than argue the actual percentage figure that you just pulled
>>>> out of your ass, I'll just point out that you're a lying sack of shit,
>>>> and that you admitted that Democrats caused the problems, too.
>>>
>>> Since 1981 (raygun years)---over 85% of the entire national debt today
>>> (due to republican policies and governing) was their fault.
>>
>> Thanks for admitting-- again-- that Democrats are to blame too.
>
> No, thank you

No, thank *you*, Yaeowerghoofus - you *did* admit - again - that
Democrats are to blame.

MANFRED the heat seeking OBOE

8/20/2012 5:03:00 PM

0


Like Vince Foster and Ed Wiley
those who knowingly serve an Evil
which has no justification, nor does it seek any,
get precisely what they deserve, SUICIDE or INSANITY.


Tony Scott found that the real Enemy of the State was within,
and that he made it so. OBAMA and his Cadre of President Makers
after TWO DECADES of DECEIT must be exposed and expunged.


LIBs. What PRICE their Vision?
---
Supporting him "constitutes material cooperation with intrinsic evil."
Jay Scott Newman'08 on OBAMA


http://www.strangepolitics.com/images/content/...
What do you mean WE paleface?

DEMAND TRUTH.
DESERVE PEACE.
DESERVE FREEDOM.
DEMAND COMPETANCE.
DEMAND ACCOUNTABILITY.
DEFEAT LIB STRATEGIC INSANITY.

EVIL HAS NO POWER WHEN THE GOOD REMAIN UNAFRAID.

Scout

8/21/2012 4:18:00 AM

0



<Yoorghis@Jurgis.net> wrote in message
news:n4e438dnqjm5917cem15uphtmtl5vte6fn@4ax.com...
> On Sun, 19 Aug 2012 21:44:37 -0400, "Scout"
> <me4guns@verizon.removeme.this2.nospam.net> wrote:
>
>>> "Numbers" after 2009 have to be added to the growing debt---because
>>> Obama has no independent program or policy he created.
>>
>>Doesn't matter. Until 2010 and the FY 2011 budget, Democrats had CONTROL.
>
> Look up the word "Control"
>
> Re-read 8th grade Civics related to passage of Legislation
>
> Check mirror for red face.

The Democrats had control.

They had the majority.


Scout

8/21/2012 4:18:00 AM

0



<Yoorghis@Jurgis.net> wrote in message
news:o6e438hnvbt8gvaqtga94i1mp4p5piiquj@4ax.com...
> On Sun, 19 Aug 2012 17:00:27 -0700, Klaus Schadenfreude
> <klausschadenfreude@yahoo.com> wrote:
>
>>>I admit nothing that you idiots are inferring
>>
>>Um, yeah, you did.
>>
>>You admitted that Democrats causes 15% of the problems.
>>
>>Rather than argue the actual percentage figure that you just pulled
>>out of your ass, I'll just point out that you're a lying sack of shit,
>>and that you admitted that Democrats caused the problems, too.
>
> Since 1981 (raygun years)---over 85% of the entire national debt today
> (due to republican policies and governing) was their fault.

Cite.


Scout

8/21/2012 4:19:00 AM

0



<Yoorghis@Jurgis.net> wrote in message
news:vbe438he2qom1fljr9b9b47k24pq03nhbd@4ax.com...
> On Sun, 19 Aug 2012 21:40:30 -0400, "Scout"
> <me4guns@verizon.removeme.this2.nospam.net> wrote:
>
>>> Debt grew under all administrations
>>>
>>> But ONLY under republican control (not just majority)---debt FAR
>>> outstripped revenue simply because of supply-side nonsense
>>
>>
>>So tell me....why is it that when Democrats CONTROLLED Both houses of
>>Congress and the Presidency..
>
> Democrats have not CONTROLLED government or legislation since the
> early 90's

111th Congress.

Try telling us another lie there Yoory, that one isn't going to cut it.