[Win32utils-devel] Fwd: [win32-service] 1067 Error on manual stopping of service (#9)

Daniel Berger djberg96 at gmail.com
Fri Aug 2 01:04:44 UTC 2013


Thoughts?

---------- Forwarded message ----------
From: Adrian Candaten <notifications at github.com>
Date: Thu, Aug 1, 2013 at 5:46 PM
Subject: [win32-service] 1067 Error on manual stopping of service (#9)
To: djberg96/win32-service <win32-service at noreply.github.com>


Problem

Moved my ruby services from winXP to Win7 and when I manually stop my
services, I receive a Windows error: Error 1067 - The process terminated
unexpectedly.

It seems to be the exit! in the service_stop().
Analysis

When I looked at the Daemon code, I can see that the program is waiting for
the @@hStopCompletedEvent event for which there is no setEvent().
Possible solution

Instead of the exit! in the `service_stop(), would it not be simpler to add

def service_stop
  SetEvent(@@hStopCompletedEvent)end

to the Daemon class and then the subclasses can call super instead of
exit!or not even implement it. Ie.

class RubyDaemon < Daemon
  def service_main
    log "service_main"
    while running?
      # do stuff and wait
      sleep 1
    end
    log "Never gets here"
  endend

This approach allows other working examples using the exit! to work, but
allow users to avoid it.
Possible solution # 2

Provide a method to set this event (thus hide the implementation details)
and instruct users to use exit! or the new method in their service_stop().
Sidenote

Thanks for your work (learning heaps looking at your code using ffi to
OSes) and owe you a coffee when you come to Brisbane.

—
Reply to this email directly or view it on
GitHub<https://github.com/djberg96/win32-service/issues/9>
.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/win32utils-devel/attachments/20130801/cbab99be/attachment.html>


More information about the win32utils-devel mailing list