List Info

Thread: win32/service... still with problems.




win32/service... still with problems.
user name
2006-05-22 16:53:48
> -----Original Message-----
> From: win32utils-devel-bouncesrubyforge.org 
> [mailto:win32utils-devel-bouncesrubyforge.org] On Behalf Of

> Luis Lavena
> Sent: Monday, May 22, 2006 10:01 AM
> To: win32utils-develrubyforge.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.

_______________________________________________
win32utils-devel mailing list
win32utils-develrubyforge.org
http://rubyforge.org/mailman/listinfo/win32utils-devel

win32/service... still with problems.
user name
2006-05-22 17:26:32
On 5/22/06, Berger, Daniel <Daniel.Bergerqwest.com> wrote:
>
> 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.
>

Actually, after the do nothing! you should see
"Leaving Service Main",
which don't happen (don't see why in your setup don't,
but here it do,
winxp).

> 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:
>
[...]
> Otherwise, you'll be dropping into a later part of the
script, which is
> probably not what you want.

The command part don't affect the Daemon part, both are
discarted by
the ARGV[0] and the ENV["HOMEDRIVE"]!=nil

Anyway, followed your suggestions (split the ctrl and the
daemon),
with the same result:

2006-05-22 14:19:50 - ** Dead Simple Service starting...
2006-05-22 14:19:52 - ** Done initialization.
2006-05-22 14:19:52 - Entering Service Main
2006-05-22 14:20:00 - Stop Signal received.
do nothing!
U:/Programming/Sources/ruby/try/dead_service.rb:45:in
`service_stop':
uninitialized constant RUNNING (NameError)
	from U:/Programming/Sources/ruby/try/dead_service.rb:52:in
`service_main'
	from U:/Programming/Sources/ruby/try/dead_service.rb:63

> 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.  [...]

Removing the call to the outside function (donothing) solved
the
uninitialized constant problem, but the "Leaving
Service Main" never
shows, so looks like was terminated previously (no safe
cleanup).

-- 
Luis Lavena
Multimedia systems
-
Leaders are made, they are not born. They are made by hard
effort,
which is the price which all of us must pay to achieve any
goal that
is worthwhile.
Vince Lombardi
_______________________________________________
win32utils-devel mailing list
win32utils-develrubyforge.org
http://rubyforge.org/mailman/listinfo/win32utils-devel
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )