# Why would a DRb process shut down?

**URL:** <https://www.ruby-forum.com/t/why-would-a-drb-process-shut-down/69273>\
**Category:** Ruby\
**Created:** [September 19, 2006, 10:03pm UTC](https://www.ruby-forum.com/t/why-would-a-drb-process-shut-down/69273 "2006-09-19T22:03:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![benjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ec8ea/32.png) [@benjohnson](https://www.ruby-forum.com/u/benjohnson)\
**Post date:** [September 19, 2006, 10:03pm UTC](https://www.ruby-forum.com/t/why-would-a-drb-process-shut-down/69273/1 "2006-09-19T22:03:43Z")

</div>

I have a program that runs about 10 DRb processes. Ocassionally one of  
the processes will shut down and I will get the error telling me that it  
can not connect to the process. It is this error:

Errno::ECONNREFUSED: Connection refused - connect(2)

What causes a DRb process to shut down? If an exception is thrown and  
uncaught will that kill it? If the server has too much load will it die?

Any tips on keeping the processes running?

Any help is greatly appreciated. Thanks.

---

<div class="post-metadata">

**Author:** ![benjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ec8ea/32.png) [@benjohnson](https://www.ruby-forum.com/u/benjohnson)\
**Post date:** [September 19, 2006, 10:15pm UTC](https://www.ruby-forum.com/t/why-would-a-drb-process-shut-down/69273/2 "2006-09-19T22:15:04Z")

</div>

Ben J. wrote:

> Any help is greatly appreciated. Thanks.

Do you have Thread.abort\_on\_exception=true ? If not, a thread with an  
uncaught exception will die silently.

---

<div class="post-metadata">

**Author:** ![benjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ec8ea/32.png) [@benjohnson](https://www.ruby-forum.com/u/benjohnson)\
**Post date:** [September 19, 2006, 10:33pm UTC](https://www.ruby-forum.com/t/why-would-a-drb-process-shut-down/69273/3 "2006-09-19T22:33:08Z")

</div>

On Wed, 20 Sep 2006, Ben J. wrote:

> Any tips on keeping the processes running?

i use a technique i call ‘immortal daemon’. rq and dirwatch both use  
it. it  
works like this:

- daemon uses a well know lockfile to signal it’s existence. see my  
lockfile class for a nfs-safe impl. so, take a daemon named  
‘foo\_d’ for  
example. we’ll assume that it uses /home/$USER/.foo\_d/lock as it’s  
lockfile.

- the options given to the lockfile.lock call are to aquire the lock  
and  
fail immediately (vs waiting) if another process holds the lock.  
the  
lockfile class i wrote knows about dead processes and stale locks,  
so you  
needn’t worry about that.

- cron your daemon to start every 15 minutes. if the process isn’t  
running,  
at any time for any reason, it will be restarted. this works after  
reboot  
and for other transient (network for example) errors.

i have used this approach in production systems with great success for  
several  
years. it’s robust and does not even require root privs.

regards.

-a

---

<div class="post-metadata">

**Author:** ![benjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ec8ea/32.png) [@benjohnson](https://www.ruby-forum.com/u/benjohnson)\
**Post date:** [September 20, 2006, 1:23am UTC](https://www.ruby-forum.com/t/why-would-a-drb-process-shut-down/69273/4 "2006-09-20T01:23:52Z")

</div>

unknown wrote:

> On Wed, 20 Sep 2006, Ben J. wrote:
> 
> i have used this approach in production systems with great success for  
> several  
> years. it’s robust and does not even require root privs.
> 
> regards.
> 
> -a

Can you attach some code that I could use? I’m still kind of lost, but  
it sounds good. I really appreciate your help.
