[Backgroundrb-devel] backgroundrb fails when running as win32 service

Ezra Zygmuntowicz ezmobius at gmail.com
Fri Aug 25 11:46:21 EDT 2006

On Aug 24, 2006, at 10:21 PM, Daniel Greig wrote:

> Hi,
> I've been playing with backgroundrb to batch process a bunch of images
> on a rails server. The process is working fine when backgroundrb is
> started from the command line, but seems to choke occasionally (well,
> quite often) when running as a service. It seems to get stuck on the
> following line when moving files:
> FileUtils.move(src, dest, :verbose => true)
> with the error:
> Bad file descriptor - (Errno::EBADF)
> For a while I thought it may have been a file permissions/file access
> issue, but I have seen another error where the process fails at a  
> "puts"
> statement. I have a suspicion that the error may be occurring when  
> ruby
> tries to write to the standard output using "puts". Since the  
> "verbose"
> argument  sends a message to the standard output, it could be failing
> for the same reason and just looking like a file move error.
> I have removed all puts statements and all verbose method calls and  
> the
> service *seems* to be more reliable (although it's to early to say  
> as I
> have to do a lot more testing). Has anyone seen any similar problems
> with the win32 service?
> My fingers are crossed that getting rid of the puts statements  
> fixes the
> problem, but I'm nervous that it may be something else entirely -  
> anyone
> have any ideas?
> thanks!
> Dan

Hey Dan-

	Unfortunately I don't have any windows boxes for testing the service  
part with. But from what I know of windows services you are correct,  
I think the errors you are getting are from using puts or print to  
stdout which seems to be closed or unavailable when running as a  
service. So as long as you don't use puts or print and instead use  
the @logger you should be fine.

	I also wonder if there is a way to redirect stdout to the log file  
on windows? If you get a chance to investigate then please let me  
know what you find out. For now you will probably have to not use the  
verbose option and make sure you use the log instead of puts.


More information about the Backgroundrb-devel mailing list