# Problem with daemonize

**URL:** <https://www.ruby-forum.com/t/problem-with-daemonize/145108>\
**Category:** Mongrel\
**Created:** [August 6, 2008, 3:52am UTC](https://www.ruby-forum.com/t/problem-with-daemonize/145108 "2008-08-06T03:52:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![skiz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e99b99/32.png) [@skiz](https://www.ruby-forum.com/u/skiz)\
**Post date:** [August 6, 2008, 3:52am UTC](https://www.ruby-forum.com/t/problem-with-daemonize/145108/1 "2008-08-06T03:52:43Z")

</div>

Hi,

I am new to working with mongrel (and rails in general) and I am  
experiencing a problem with mongrel. I have a rails application that  
for one view parses some information from our SVN server. I have to  
call the SVN several times to get all the information I need and it  
takes about 30 sec. to complete the request (This is ok because it is an  
internal app). The problem is that this only works when I run mongrel  
non daemonized. If I deamonize the process the rest of my rails site  
works fine. But, this page hangs when I try to load it. I have looked  
through the mongrel.log, error.log, and development.log (still using the  
development environment) and I cannot find any errors. The web browser  
(firefox 3) just sits there and acts like it loads the page but nothing  
happens. Does anybody know what might be the problem? It seams weird  
to me that it works when non deamonized but does not work when mongrel  
is run as a deamon.

Thanks for any ideas.

Josh

---

<div class="post-metadata">

**Author:** ![skiz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e99b99/32.png) [@skiz](https://www.ruby-forum.com/u/skiz)\
**Post date:** [August 6, 2008, 4:07am UTC](https://www.ruby-forum.com/t/problem-with-daemonize/145108/2 "2008-08-06T04:07:57Z")

</div>

> > > > > “Josh” == Josh M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:  
> > > > > Josh\> happens. Does anybody know what might be the problem? It  
> > > > > seams weird  
> > > > > Josh\> to me that it works when non deamonized but does not work when  
> > > > > mongrel  
> > > > > Josh\> is run as a deamon.

When daemonized, does it run as you, or as another user?  
When it hangs, do you see “svn” processes waiting in the ps listing?  
Do you get errors from the popen calls that you are doing?  
Do you get anything when you look at the page source for the page that  
loads?

–  
Michael R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Director – Consumer Desktop Development, Simtone Corporation, Ottawa,  
Canada  
Personal: [Michael Richardson's Directory](http://www.sandelman.ca/mcr/)

SIMtone Corporation fundamentally transforms computing into simple,  
secure, and very low-cost network-provisioned services pervasively  
accessible by everyone. Learn more at [www.simtone.net](http://www.simtone.net) and  
[www.SIMtoneVDU.com](http://www.SIMtoneVDU.com)

---

<div class="post-metadata">

**Author:** ![skiz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e99b99/32.png) [@skiz](https://www.ruby-forum.com/u/skiz)\
**Post date:** [August 6, 2008, 4:37am UTC](https://www.ruby-forum.com/t/problem-with-daemonize/145108/3 "2008-08-06T04:37:23Z")

</div>

> When daemonized, does it run as you, or as another user?  
> The deamonized process runs as me.

> When it hangs, do you see “svn” processes waiting in the ps listing?  
> There is no svn process in the ps listing (“ps afx | grep svn”)

> Do you get errors from the popen calls that you are doing?  
> It actually hangs on the call and I do not get any output.

> Do you get anything when you look at the page source for the page that  
> loads?  
> I get this “”

Thanks,

Josh

unknown wrote:

> > > > > > “Josh” == Josh M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:  
> > > > > > Josh\> happens. Does anybody know what might be the problem? It  
> > > > > > seams weird  
> > > > > > Josh\> to me that it works when non deamonized but does not work when  
> > > > > > mongrel  
> > > > > > Josh\> is run as a deamon.
> 
> When daemonized, does it run as you, or as another user?  
> When it hangs, do you see “svn” processes waiting in the ps listing?  
> Do you get errors from the popen calls that you are doing?  
> Do you get anything when you look at the page source for the page that  
> loads?
> 
> –  
> Michael R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> Director – Consumer Desktop Development, Simtone Corporation, Ottawa,  
> Canada  
> Personal: [Michael Richardson's Directory](http://www.sandelman.ca/mcr/)
> 
> SIMtone Corporation fundamentally transforms computing into simple,  
> secure, and very low-cost network-provisioned services pervasively  
> accessible by everyone. Learn more at [www.simtone.net](http://www.simtone.net) and  
> [www.SIMtoneVDU.com](http://www.SIMtoneVDU.com)

---

<div class="post-metadata">

**Author:** ![skiz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e99b99/32.png) [@skiz](https://www.ruby-forum.com/u/skiz)\
**Post date:** [August 6, 2008, 3:22pm UTC](https://www.ruby-forum.com/t/problem-with-daemonize/145108/4 "2008-08-06T15:22:26Z")

</div>

> > > > > “Josh” == Josh M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:  
> > > > > When daemonized, does it run as you, or as another user?  
> > > > > Josh\> The deamonized process runs as me.

```
>> When it hangs, do you see "svn" processes waiting in the ps 

```

listing?  
Josh\> There is no svn process in the ps listing (“ps afx | grep  
svn”)

```
>> Do you get errors from the popen calls that you are doing?
Josh> It actually hangs on the call and I do not get any output.

```

I would run “strace -f -p XXXX” on the mongrel process(es), and try  
things. I would suspect either that the exec part of the popen() fails  
due to $PATH issues. Since there is no “svn” process around, then it  
should not be an issue with the underlying ssh that might be invoked.  
You might also replace the call to svn with echo/cat/env.

instead of:  
foo = IO.popen(“svn stuff”, “r”)

do:  
foo = IO.popen(“sh -c ‘env \>/tmp/env$$; cat /tmp/canned-svn-reply’”,  
“r”)

and if that helps diag things.

–  
Michael R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Director – Consumer Desktop Development, Simtone Corporation, Ottawa,  
Canada  
Personal: [Michael Richardson's Directory](http://www.sandelman.ca/mcr/)

SIMtone Corporation fundamentally transforms computing into simple,  
secure, and very low-cost network-provisioned services pervasively  
accessible by everyone. Learn more at [www.simtone.net](http://www.simtone.net) and  
[www.SIMtoneVDU.com](http://www.SIMtoneVDU.com)

---

<div class="post-metadata">

**Author:** ![skiz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e99b99/32.png) [@skiz](https://www.ruby-forum.com/u/skiz)\
**Post date:** [August 14, 2008, 6:18am UTC](https://www.ruby-forum.com/t/problem-with-daemonize/145108/5 "2008-08-14T06:18:59Z")

</div>

Hi,

Sorry it took so long have been called way to other projects. Now that  
I am back I have been doing some looking and it seams whenever I try to  
access the file system (even to run an ‘ls’ or ‘pwd’ command) it spawns  
another mongrel and hangs. The last line in the strace log:

20558 select(4, [3], [2], [], {0, 871586}) = -1 EBADF (Bad file  
descriptor)

This line prints a huge number of times in a very very short period of  
time (I shortend the log so that it would be smaller. But it printed  
this line in the order of 100,000 times in a couple of minutes). Even  
when I run as the root user this same thing happens.

I have attached the strace log because I have looked at it but cannot  
really make heads or tails of what it means. Thanks, for all ideas.

Josh

P.S. Sorry, the strace file is about 400k and is to big to attach. If  
anybody is willing to look at it please just email me  
removed\_email\_address@domain.invalid and I will be happy to send it to you.

unknown wrote:

> > > > > > “Josh” == Josh M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:  
> > > > > > When daemonized, does it run as you, or as another user?  
> > > > > > Josh\> The deamonized process runs as me.
> 
> ```
> >> When it hangs, do you see "svn" processes waiting in the ps 
> 
> ```
> 
> listing?  
> Josh\> There is no svn process in the ps listing (“ps afx | grep  
> svn”)
> 
> ```
> >> Do you get errors from the popen calls that you are doing?
> Josh> It actually hangs on the call and I do not get any output.
> 
> ```
> 
> I would run “strace -f -p XXXX” on the mongrel process(es), and try  
> things. I would suspect either that the exec part of the popen() fails  
> due to $PATH issues. Since there is no “svn” process around, then it  
> should not be an issue with the underlying ssh that might be invoked.  
> You might also replace the call to svn with echo/cat/env.
> 
> instead of:  
> foo = IO.popen(“svn stuff”, “r”)
> 
> do:  
> foo = IO.popen(“sh -c ‘env \>/tmp/env$$; cat /tmp/canned-svn-reply’”,  
> “r”)
> 
> and if that helps diag things.
> 
> –  
> Michael R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> Director – Consumer Desktop Development, Simtone Corporation, Ottawa,  
> Canada  
> Personal: [Michael Richardson's Directory](http://www.sandelman.ca/mcr/)
> 
> SIMtone Corporation fundamentally transforms computing into simple,  
> secure, and very low-cost network-provisioned services pervasively  
> accessible by everyone. Learn more at [www.simtone.net](http://www.simtone.net) and  
> [www.SIMtoneVDU.com](http://www.SIMtoneVDU.com)
