问题
I am using this gem: win32-service (0.7.2 x86-mingw32)
The gem has a demo_daemon.rb and a demo_daemon_ctl.rb in the example directory. I have tried to run the example as a service using both ruby 1.8.7 and 1.9.3 and I get the error below. The daemon tries to write to a log file, but it never reaches a point where the log file gets written. Even if I put a log write on startup of the script nothing gets written.
My machine is 64 bit.
Any ideas on what I can try or what could be the issue?
C:/Ruby193/lib/ruby/gems/1.9.1/gems/win32-service-0.7.2-x86-mingw32/lib/win32/se
rvice.rb:760:in `start': The service did not respond to the start or control req
uest in a timely fashion. (Win32::Service::Error)
from demo_daemon_ctl.rb:75:in `<main>'
回答1:
I think you need use a service wrapper such as srvany . Here is the Microsoft's guide. Use full path for both ruby and the script in the "Application" parameter. And if something goes wrong under 64bit system, just put the srvany.exe in both windows/system32 and windows/sysWow64 folder.
来源:https://stackoverflow.com/questions/15394683/running-windows-service-in-ruby-on-windows-7