 |
Forums |
Admin Start New Thread
By: Daniel Berger
RE: Win32 Service not working [ reply ] 2006-08-22 04:45
|
Hi Jim,
Ok, I see a couple issues. First, that gem is outdated. It's actually not published by me. Grab 0.5.1 from the RAA and build it manually. If you don't have a compiler, you can grab the .so file from the "Files" section. Be sure to rename it to just 'service.so' and copy it in the appropriate directory. That's not really the issue, though.
Second, the example in daemon_test.rb needs some minor tweaking. Remove the 's.dependencies = []' line from daemon_test.rb (which was a workaround for a bug that has since been squashed). Also, replace 'ruby ' with "C:\\ruby\bin\\ruby ".
Really, the only issue is using the full path to ruby.exe. Once I did that it worked fine.
HTH,
Dan
|
By: Jim Freeze
RE: Win32 Service not working [ reply ] 2006-08-22 02:52
|
Here are the results of the example program, showing how it fails out of the box.
I have a new xp pro machine on which I installed ruby with the one-click installer. I installed gems, then ran the example program.
The results are below.
c:\ruby>gem install win32-service
Bulk updating Gem source index for: http://gems.rubyforge.org
Select which gem to install for your platform (i386-mswin32)
1. win32-service 0.5.0 (mswin32)
2. Cancel installation
> 1
Successfully installed win32-service-0.5.0-mswin32
Installing ri documentation for win32-service-0.5.0-mswin32...
Installing RDoc documentation for win32-service-0.5.0-mswin32...
c:\ruby>cd lib\ruby\gems\1.8\gems\win32-service-0.5.0-mswin32\examples
C:\ruby\lib\ruby\gems\1.8\gems\win32-service-0.5.0-mswin32\examples>ruby daemon_
test.rb install
VERSION: 0.5.0
installed
C:\ruby\lib\ruby\gems\1.8\gems\win32-service-0.5.0-mswin32\examples>ruby daemon_
test.rb start
VERSION: 0.5.0
daemon_test.rb:56:in `start': The system cannot find the file specified. (Win32:
:ServiceError)
from daemon_test.rb:56
C:\ruby\lib\ruby\gems\1.8\gems\win32-service-0.5.0-mswin32\examples>
|
By: Jim Freeze
Win32 Service not working [ reply ] 2006-08-21 20:05
|
Can't get a ruby app to install as a service. Here is the code:
require 'rubygems'
require 'win32/service'
require 'pp'
include Win32
puts "VERSION: " + Service::VERSION
MACHINE = "ToothFairySR"
SERVICE_NAME = "PCRmtCmdSvc"
SERVICE_DISPLAYNAME = "PCRmtCmd"
Service.delete SERVICE_NAME if Service.exists?(SERVICE_NAME)
if Service.exists?(SERVICE_NAME)
status = Service.status(SERVICE_NAME)
puts status
else
# Create a new service
svc = Service.new #(MACHINE)
svc.create_service{ |s|
s.service_name = SERVICE_NAME
s.display_name = SERVICE_DISPLAYNAME
s.binary_path_name = "C:\\ruby\\bin\\ruby.exe"
#s.binary_path_name = 'c:/ruby/bin/ruby.exe ' + File.join("C:", "osql", "foo.rb")
#s.binary_path_name = File.join("C:", "osql", "foo.rb")
#s.binary_path_name = 'ruby ' + File.join("C:", "osql", "foo.rb")
#s.binary_path_name = %Q{c:/ruby/bin/ruby.exe -e 'p "hi"*800; sleep 4'}
#s.binary_path_name = 'c:/windows/system32/notepad.exe'
#s.binary_path_name = "ruby C:\\osql\\foo.rb"
#s.binary_path_name = 'ruby.exe ' + File.expand_path($0)
p s.binary_path_name
s.dependencies = []
}
svc.close
puts "Service '#{SERVICE_NAME}' installed"
end
Service.start(SERVICE_NAME)
puts Service.status(SERVICE_NAME)
started = false
while started == false
s = Service.status(SERVICE_NAME)
started = true if s.current_state == "running"
break if started == true
puts "One moment, " + s.current_state
sleep 1
end
puts "Ok, started"
|
|
 |