<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Making sure Ruby Daemons die</title>
	<atom:link href="http://blog.rapleaf.com/dev/2008/02/15/making-sure-ruby-daemons-die/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.rapleaf.com/dev/2008/02/15/making-sure-ruby-daemons-die/</link>
	<description>For engineers by engineers</description>
	<lastBuildDate>Wed, 08 Sep 2010 23:31:23 -0700</lastBuildDate>
	
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: gemFinder</title>
		<link>http://blog.rapleaf.com/dev/2008/02/15/making-sure-ruby-daemons-die/comment-page-1/#comment-1600</link>
		<dc:creator>gemFinder</dc:creator>
		<pubDate>Mon, 21 Jun 2010 00:04:14 +0000</pubDate>
		<guid isPermaLink="false">http://blog.rapleaf.com/dev/?p=19#comment-1600</guid>
		<description>great extension , thanks</description>
		<content:encoded><![CDATA[<p>great extension , thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: links for 2010-02-09 &#171; Bloggitation</title>
		<link>http://blog.rapleaf.com/dev/2008/02/15/making-sure-ruby-daemons-die/comment-page-1/#comment-1497</link>
		<dc:creator>links for 2010-02-09 &#171; Bloggitation</dc:creator>
		<pubDate>Wed, 10 Feb 2010 06:05:33 +0000</pubDate>
		<guid isPermaLink="false">http://blog.rapleaf.com/dev/?p=19#comment-1497</guid>
		<description>[...] Making sure Ruby Daemons die (tags: ruby sysadmin) [...]</description>
		<content:encoded><![CDATA[<p>[...] Making sure Ruby Daemons die (tags: ruby sysadmin) [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Irish</title>
		<link>http://blog.rapleaf.com/dev/2008/02/15/making-sure-ruby-daemons-die/comment-page-1/#comment-1432</link>
		<dc:creator>Irish</dc:creator>
		<pubDate>Tue, 15 Dec 2009 23:03:20 +0000</pubDate>
		<guid isPermaLink="false">http://blog.rapleaf.com/dev/?p=19#comment-1432</guid>
		<description>Thanks Chris and Seamus, this fix &amp; gem was exactly what I needed :-)</description>
		<content:encoded><![CDATA[<p>Thanks Chris and Seamus, this fix &amp; gem was exactly what I needed <img src='http://blog.rapleaf.com/dev/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: The Daemons are Dead (long live the Daemons) &#171; reevoolabs</title>
		<link>http://blog.rapleaf.com/dev/2008/02/15/making-sure-ruby-daemons-die/comment-page-1/#comment-1418</link>
		<dc:creator>The Daemons are Dead (long live the Daemons) &#171; reevoolabs</dc:creator>
		<pubDate>Tue, 24 Nov 2009 17:50:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.rapleaf.com/dev/?p=19#comment-1418</guid>
		<description>[...] This problem has thankfully been solved by the use of RapLeafs&#8217; daemon_extension code which is basically a bundle of hacks to kill -9 a daemon that refuses to die after a certain timeout period. This isn&#8217;t perfect by any stretch of the imagination, but from a pragmatists point of view: It&#8217;ll do! [...]</description>
		<content:encoded><![CDATA[<p>[...] This problem has thankfully been solved by the use of RapLeafs&#8217; daemon_extension code which is basically a bundle of hacks to kill -9 a daemon that refuses to die after a certain timeout period. This isn&#8217;t perfect by any stretch of the imagination, but from a pragmatists point of view: It&#8217;ll do! [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Greg Hazel</title>
		<link>http://blog.rapleaf.com/dev/2008/02/15/making-sure-ruby-daemons-die/comment-page-1/#comment-1308</link>
		<dc:creator>Greg Hazel</dc:creator>
		<pubDate>Wed, 26 Aug 2009 19:59:18 +0000</pubDate>
		<guid isPermaLink="false">http://blog.rapleaf.com/dev/?p=19#comment-1308</guid>
		<description>As Tony said, that is just a wait function. In fact, the Daemons library already uses kill(0, pid) to implement Daemons::Pid.running?(pid), and as noted there kill(0, pid) does not send a signal; it&#039;s just a syscall to see if a signal may be sent.

So you can see where it fits into the Daemons code, and so there&#039;s a gem, I&#039;ve made a github repo out of the Daemons SVN repository:
http://github.com/ghazel/daemons/

Here is the relevant commit:
http://github.com/ghazel/daemons/commit/3e91f91c5a95409bdbd54039e4163ea509d66619</description>
		<content:encoded><![CDATA[<p>As Tony said, that is just a wait function. In fact, the Daemons library already uses kill(0, pid) to implement Daemons::Pid.running?(pid), and as noted there kill(0, pid) does not send a signal; it&#8217;s just a syscall to see if a signal may be sent.</p>
<p>So you can see where it fits into the Daemons code, and so there&#8217;s a gem, I&#8217;ve made a github repo out of the Daemons SVN repository:<br />
<a href="http://github.com/ghazel/daemons/" rel="nofollow">http://github.com/ghazel/daemons/</a></p>
<p>Here is the relevant commit:<br />
<a href="http://github.com/ghazel/daemons/commit/3e91f91c5a95409bdbd54039e4163ea509d66619" rel="nofollow">http://github.com/ghazel/daemons/commit/3e91f91c5a95409bdbd54039e4163ea509d66619</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Armstrong</title>
		<link>http://blog.rapleaf.com/dev/2008/02/15/making-sure-ruby-daemons-die/comment-page-1/#comment-1267</link>
		<dc:creator>Brian Armstrong</dc:creator>
		<pubDate>Wed, 12 Aug 2009 01:43:54 +0000</pubDate>
		<guid isPermaLink="false">http://blog.rapleaf.com/dev/?p=19#comment-1267</guid>
		<description>Thanks for posting this, I was having the same problem.

I ended up switching to the daemons-spawn gem instead using instructions here and that also fixed it:
http://rwldesign.com/journals/1-solutions/posts/24-working-with-delayed-job

One drawback is the daemons-gem script doesn&#039;t (yet) support multiple workers with a -n option (it only launches one).  Probably wouldn&#039;t be too hard to modify it.  Anyway, just wanted to post another solution.

delayed_job should really update their daemonizing instructions on github!  As evidenced by this thread, what they have posted is not stable in production.

Thanks!
Brian
http://feedmailpro.com</description>
		<content:encoded><![CDATA[<p>Thanks for posting this, I was having the same problem.</p>
<p>I ended up switching to the daemons-spawn gem instead using instructions here and that also fixed it:<br />
<a href="http://rwldesign.com/journals/1-solutions/posts/24-working-with-delayed-job" rel="nofollow">http://rwldesign.com/journals/1-solutions/posts/24-working-with-delayed-job</a></p>
<p>One drawback is the daemons-gem script doesn&#8217;t (yet) support multiple workers with a -n option (it only launches one).  Probably wouldn&#8217;t be too hard to modify it.  Anyway, just wanted to post another solution.</p>
<p>delayed_job should really update their daemonizing instructions on github!  As evidenced by this thread, what they have posted is not stable in production.</p>
<p>Thanks!<br />
Brian<br />
<a href="http://feedmailpro.com" rel="nofollow">http://feedmailpro.com</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tony Payne</title>
		<link>http://blog.rapleaf.com/dev/2008/02/15/making-sure-ruby-daemons-die/comment-page-1/#comment-1213</link>
		<dc:creator>Tony Payne</dc:creator>
		<pubDate>Wed, 22 Jul 2009 03:06:37 +0000</pubDate>
		<guid isPermaLink="false">http://blog.rapleaf.com/dev/?p=19#comment-1213</guid>
		<description>Note that Greg&#039;s code is merely a wait function, not a kill. It continues to loop as long as the process exists. kill -0 does not signal the process, but instead returns true if the process is alive, false otherwise. It&#039;s a pretty standard kill value.</description>
		<content:encoded><![CDATA[<p>Note that Greg&#8217;s code is merely a wait function, not a kill. It continues to loop as long as the process exists. kill -0 does not signal the process, but instead returns true if the process is alive, false otherwise. It&#8217;s a pretty standard kill value.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike Ayers</title>
		<link>http://blog.rapleaf.com/dev/2008/02/15/making-sure-ruby-daemons-die/comment-page-1/#comment-1210</link>
		<dc:creator>Mike Ayers</dc:creator>
		<pubDate>Mon, 20 Jul 2009 23:51:12 +0000</pubDate>
		<guid isPermaLink="false">http://blog.rapleaf.com/dev/?p=19#comment-1210</guid>
		<description>Signal 0 is, as best I can tell, a meta-signal that causes an exception if the process does not exist.  I saw it in some Ruby code, which I copied, then discovered that this signal is not only not POSIX, it&#039;s not even uniformly supported on Linux!  I think Greg meant &quot;Process.kill(&#039;TERM&#039;, pid)&quot;, as signal 0 would not stop anything.</description>
		<content:encoded><![CDATA[<p>Signal 0 is, as best I can tell, a meta-signal that causes an exception if the process does not exist.  I saw it in some Ruby code, which I copied, then discovered that this signal is not only not POSIX, it&#8217;s not even uniformly supported on Linux!  I think Greg meant &#8220;Process.kill(&#8216;TERM&#8217;, pid)&#8221;, as signal 0 would not stop anything.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: chris</title>
		<link>http://blog.rapleaf.com/dev/2008/02/15/making-sure-ruby-daemons-die/comment-page-1/#comment-1044</link>
		<dc:creator>chris</dc:creator>
		<pubDate>Sun, 08 Mar 2009 17:21:49 +0000</pubDate>
		<guid isPermaLink="false">http://blog.rapleaf.com/dev/?p=19#comment-1044</guid>
		<description>Hi Greg,
We&#039;re always looking for ways to simplify code, so thanks for the ideas.  I have a couple of questions:

1. What signal does &#039;0&#039; correspond to (in &#039;Process.kill(0, pid)&#039;)?  On both my Mac and CentOS, TERM is &#039;15&#039; and KILL is &#039;9&#039;.  Maybe I&#039;m just missing something...
2. Does this work with :multiple =&gt; true?  Perhaps it would help to see where this fits into the Daemons code.

Our use cases might be very different, but it is important for us to receive feedback via STDOUT along the way.  In your solution, we could just add a &#039;puts&#039; in the while loop, but we probably wouldn&#039;t want that message to appear 10 times a second.  That brings up another subtle difference.  In your solution, a signal is sent after every sleep period.  In our solution we send a TERM signal, then wait a configurable amount of time for the process to exit gracefully before sending the KILL signal.</description>
		<content:encoded><![CDATA[<p>Hi Greg,<br />
We&#8217;re always looking for ways to simplify code, so thanks for the ideas.  I have a couple of questions:</p>
<p>1. What signal does &#8216;0&#8242; correspond to (in &#8216;Process.kill(0, pid)&#8217;)?  On both my Mac and CentOS, TERM is &#8216;15&#8242; and KILL is &#8216;9&#8242;.  Maybe I&#8217;m just missing something&#8230;<br />
2. Does this work with :multiple => true?  Perhaps it would help to see where this fits into the Daemons code.</p>
<p>Our use cases might be very different, but it is important for us to receive feedback via STDOUT along the way.  In your solution, we could just add a &#8216;puts&#8217; in the while loop, but we probably wouldn&#8217;t want that message to appear 10 times a second.  That brings up another subtle difference.  In your solution, a signal is sent after every sleep period.  In our solution we send a TERM signal, then wait a configurable amount of time for the process to exit gracefully before sending the KILL signal.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Greg Hazel</title>
		<link>http://blog.rapleaf.com/dev/2008/02/15/making-sure-ruby-daemons-die/comment-page-1/#comment-1039</link>
		<dc:creator>Greg Hazel</dc:creator>
		<pubDate>Fri, 27 Feb 2009 09:14:36 +0000</pubDate>
		<guid isPermaLink="false">http://blog.rapleaf.com/dev/?p=19#comment-1039</guid>
		<description>Ok, more than one line. Process.wait doesn&#039;t work because the pid is not a child of the process that is stopping everything. Instead you need:

def fancy_wait pid
    begin
        while (1) do
            Process.kill(0, pid)
            sleep 0.1
        end
    rescue Errno::ESRCH, Errno::ECHILD
    end
end</description>
		<content:encoded><![CDATA[<p>Ok, more than one line. Process.wait doesn&#8217;t work because the pid is not a child of the process that is stopping everything. Instead you need:</p>
<p>def fancy_wait pid<br />
    begin<br />
        while (1) do<br />
            Process.kill(0, pid)<br />
            sleep 0.1<br />
        end<br />
    rescue Errno::ESRCH, Errno::ECHILD<br />
    end<br />
end</p>
]]></content:encoded>
	</item>
</channel>
</rss>
