# A dRuby application running as a Windows service?

**URL:** <https://www.ruby-forum.com/t/a-druby-application-running-as-a-windows-service/47849>\
**Category:** Ruby\
**Created:** [November 14, 2005, 4:14pm UTC](https://www.ruby-forum.com/t/a-druby-application-running-as-a-windows-service/47849 "2005-11-14T16:14:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dominic.marks](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/48db29/32.png) [@dominic.marks](https://www.ruby-forum.com/u/dominic.marks)\
**Post date:** [November 14, 2005, 4:14pm UTC](https://www.ruby-forum.com/t/a-druby-application-running-as-a-windows-service/47849/1 "2005-11-14T16:14:07Z")

</div>

Hello,

I’m attempting to write a small druby application which will run on our  
network of Windows PCs. The application will run in the background and  
allow  
some methods to be used on the client PCs. This application needs to run  
invisibly on the client PCs so I have installed the script as a service  
using SRYANY.EXE, I first tried using the win32-service module, and  
while I  
could install the service properly I could not get it to start.

Now I have the script installed and it will start correctly on the  
Windows  
PC. Now I try and call a method via druby the client script hangs  
indefinitely and the method never appears to return.

This happens even for a trivial ‘ping’ method, so I know it is not  
hanging  
in the method I’m calling.

Has anyone had any success in writing a druby application running as a  
service on Windows? I’ve used druby extensively on Windows without  
problems  
before now, but I’ve never used it as a service.

My best guess is that for some reason creating the thread when running  
as a  
service is stalling somewhere, but that is just a guess.

Example dRuby Application:

> 

require ‘drb/drb’  
require ‘thread’

class SampleServer  
def ping  
“pong”  
end  
end

DRb.start\_service(“druby://:1234”, SampleServer.new)  
DRb.thread.join  
\<

Example dRuby Client:

> 

require ‘drb/drb’

DRb.start\_service  
drb = DRbObject.new(nil, “druby://localhost:1234”)  
puts drb.ping  
\<

If I run the server and client in console windows on the system,  
everything  
works as expected. Only when running as a service do the druby calls  
hang  
when calling the method on the druby server.

Any clues?

Thanks,

---

<div class="post-metadata">

**Author:** ![dominic.marks](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/48db29/32.png) [@dominic.marks](https://www.ruby-forum.com/u/dominic.marks)\
**Post date:** [November 14, 2005, 4:38pm UTC](https://www.ruby-forum.com/t/a-druby-application-running-as-a-windows-service/47849/2 "2005-11-14T16:38:09Z")

</div>

Dominic M. wrote:

> Hello,
> 
> I’m attempting to write a small druby application which will run on our  
> network of Windows PCs. The application will run in the background and allow  
> some methods to be used on the client PCs. This application needs to run  
> invisibly on the client PCs so I have installed the script as a service  
> using SRYANY.EXE, I first tried using the win32-service module, and while I  
> could install the service properly I could not get it to start.

In the latest version of KirbyBase I just released  
([http://netpromi.com/kirbybase\_ruby.html](http://netpromi.com/kirbybase_ruby.html)), I have an example script of  
how to run the server, which is a druby app, as a Windows Service using  
win32-service. I pretty much stole two of Daniel B.'s sample  
scripts and changed a few lines of code and it worked.

Daniel would be the one to answer any complex questions about this, but  
if you want to see my examples, you can download the KirbyBase  
distribution and look in the examples/kbserver\_as\_win32\_service  
directory.

HTH,

Jamey

Confidentiality Notice: This email message, including any attachments,  
is for the sole use of the intended recipient(s) and may contain  
confidential and/or privileged information. If you are not the intended  
recipient(s), you are hereby notified that any dissemination,  
unauthorized review, use, disclosure or distribution of this email and  
any materials contained in any attachments is prohibited. If you receive  
this message in error, or are not the intended recipient(s), please  
immediately notify the sender by email and destroy all copies of the  
original message, including attachments.
