[Win32utils-devel] win32/service... still with problems.

Berger, Daniel Daniel.Berger at Qwest.com
Mon May 22 12:53:48 EDT 2006


> -----Original Message-----
> From: win32utils-devel-bounces at rubyforge.org 
> [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of 
> Luis Lavena
> Sent: Monday, May 22, 2006 10:01 AM
> To: win32utils-devel at rubyforge.org
> Subject: [Win32utils-devel] win32/service... still with problems.
> 
> 
> Hello list,
> 
> In my quest to get Mongrel working as service for win32, 
> found some problems with win32/service that make it 
> impossible to solve.
> 
> Attached is the simplest service script I could do with ruby, 
> which depends on win32/service.
> 
> I found that doing anything complex in service_stop (killing 
> threads, doing file handling, even sleeping for 0.25 
> seconds). crash the service with backtraces (of the service) 
> like this:
> 
> dead_service.rb:119:in `service_main': uninitialized constant RUNNING
> (NameError)
> 	from U:/Programming/Sources/ruby/try/dead_service.rb:131

Where does this backtrace go?  I don't see anything like that when I
tail the log file:

2006-05-22 10:38:48 - ** Dead Simple Service starting...
2006-05-22 10:38:50 - ** Done initialization.
2006-05-22 10:38:50 - Entering Service Main
do nothing!

I have no idea why you're seeing that error.  I don't see it.

There are a couple of issues with your script (which may actually be
issues with our sample script).  You should re-raise exceptions or exit
when one of the commands fails.  For example:

rescue Win32::ServiceError => err
   puts "There was a problem installing the service:"
   puts err
end

Should be:

rescue Win32::ServiceError => err
   puts "There was a problem installing the service:"
   puts err
   raise
end

Otherwise, you'll be dropping into a later part of the script, which is
probably not what you want.
 
> Or: I'm doing something wrong (in which case please enlighten 
> me) or there is something wrong on how the threading model is 
> implemented? (and the mix of C threads with ruby threads).

I think one thing you'll want to avoid is having a Daemon calling
methods outside of itself, as you're doing with the 'log' method there,
which may be the source of the problem.  Although the example we ship
with the win32-service package mixes the command line stuff with the
actual Daemon code, in practice I separate the actual Daemon class and
the controller script into separate files.  It's a good sanity preserver
I've found.

Dan


This communication is the property of Qwest and may contain confidential or
privileged information. Unauthorized use of this communication is strictly 
prohibited and may be unlawful.  If you have received this communication 
in error, please immediately notify the sender by reply e-mail and destroy 
all copies of the communication and any attachments.



More information about the win32utils-devel mailing list