Ruby scripts as Win32-Service

I've through together a ruby script as test for a monitoring app for a few
Win32 user processes I'm stuck with supporting. I've gotten most of the
management setup, however, I'm stuck trying to figure out how to run the
script as a service. I tried creating the service manually with
sc.exe<http://support.microsoft.com/?kbid=251192>,
with both the script and a call to c:\ruby\bin\rubyw.exe with the filename
as the argument, but I receive a time-out. I spent some time with google,
but perhaps I'm missing something silly?

Does win32-service do something special when creating a service that I'm
missing with the manual service creation? I suppose I could always run it
via the startup folder, but I thought this would be cleaner.

Thanks,

William Ramirez

You did "install" the service using win3-service right? (just asking)

pth

···

On 2/17/06, William Ramirez <mercan01@gmail.com> wrote:

I've through together a ruby script as test for a monitoring app for a few
Win32 user processes I'm stuck with supporting. I've gotten most of the
management setup, however, I'm stuck trying to figure out how to run the
script as a service. I tried creating the service manually with
sc.exe<Microsoft Support,
with both the script and a call to c:\ruby\bin\rubyw.exe with the filename
as the argument, but I receive a time-out. I spent some time with google,
but perhaps I'm missing something silly?

Does win32-service do something special when creating a service that I'm
missing with the manual service creation? I suppose I could always run it
via the startup folder, but I thought this would be cleaner.

Thanks,

William Ramirez

Nope, I used the command sc.exe, which allows you to create services. I
didn't see the need to create an 'installer' just for testing purposes. I
browsed the win32-service documentation and it didn't appear to do anything
special with regards to service creation.

···

On 2/17/06, Patrick Hurley <phurley@gmail.com> wrote:

You did "install" the service using win3-service right? (just asking)

I did this at $WORK a while back (with ActivePerl rather than Ruby).
I used SRVANY.EXE (from the Windows NT Resource Kit), which is a
wrapper that turns any executable into a Windows service. You
register SRVANY.EXE as the service, then create Registry keys to tell
it which program to run (RUBY.EXE, I guess), what arguments to give it
(-w my_script.rb) and what directory to run it in. I'm not at work
right now so I'm short of details but IIRC it was quite
straightforward. Googling for SRVANY.EXE turns up
<URL:http://www.liutilities.com/products/wintaskspro/processlibrary/srvany&gt;,
"srvany.exe is an additional Microsoft Windows application which
allows an executable to be ran as a service.". Hope this helps.

Cheers,

Jeremy Henty

···

On 2006-02-18, Patrick Hurley <phurley@gmail.com> wrote:

On 2/17/06, William Ramirez <mercan01@gmail.com> wrote:

... I'm stuck trying to figure out how to run the script as a
service.

It's not a traditional installer; it's registering the service. Look
at what Ruwiki does for service management in its command-line.

-austin

···

On 2/17/06, William Ramirez <mercan01@gmail.com> wrote:

On 2/17/06, Patrick Hurley <phurley@gmail.com> wrote:
> You did "install" the service using win3-service right? (just asking)
Nope, I used the command sc.exe, which allows you to create services. I
didn't see the need to create an 'installer' just for testing purposes. I
browsed the win32-service documentation and it didn't appear to do anything
special with regards to service creation.

--
Austin Ziegler * halostatue@gmail.com
               * Alternate: austin@halostatue.ca

Does win32-service do something special when creating a service that I'm
missing with the manual service creation? I suppose I could always run it
via the startup folder, but I thought this would be cleaner.

Check out the instiki instructions for running a ruby script as a
windows service:

Regards,

Peter

···

-------------------------------------------------

http://www.standards-schmandards.com/

Hey I know practically nothing about Windows. Could I follow those instructions to have WEBrick always running an easily deploy a simple management Rails tool for internal usage?

-- fxn

···

On Feb 18, 2006, at 8:25, Peter Krantz wrote:

Does win32-service do something special when creating a service that I'm
missing with the manual service creation? I suppose I could always run it
via the startup folder, but I thought this would be cleaner.

Check out the instiki instructions for running a ruby script as a
windows service:

http://instiki.org/show/Running+as+a+Windows+Service

Hi Xavier,

Hey I know practically nothing about Windows. Could I follow those
instructions to have WEBrick always running an easily deploy a simple
management Rails tool for internal usage?

Few comments:
- It's very much possible to do so. I personally prefer cygwin's
cygrunsrv, but the above instructions work flawlessly.
- The service created is not a "real" win32 service - it doesn't
respond to TERM signals and the only way to stop it is to either kill
the process or build a stop command in your app.
- If you're on windows, why not go with InstantRails?
(http://instantrails.rubyforge.org/\)

Cheers,
Assaph

Hi Xavier,

Hey I know practically nothing about Windows. Could I follow those
instructions to have WEBrick always running an easily deploy a simple
management Rails tool for internal usage?

Few comments:
- It's very much possible to do so. I personally prefer cygwin's
cygrunsrv, but the above instructions work flawlessly.
- The service created is not a "real" win32 service - it doesn't
respond to TERM signals and the only way to stop it is to either kill
the process or build a stop command in your app.

Nice. I'll consider this solution.

- If you're on windows, why not go with InstantRails?
(http://instantrails.rubyforge.org/\)

Because my application uses SQLite. Porting the database is an option, it's just a handful of tables, but I am exploring available solutions for ease (read as trivial as possible) deployment.

-- fxn

···

On Feb 18, 2006, at 13:57, Assaph Mehr wrote:

Because my application uses SQLite. Porting the database is an
option, it's just a handful of tables, but I am exploring available
solutions for ease (read as trivial as possible) deployment.

I developed something in house that run on WEBrick and SQLite (only
one table :). When it came time to share with others, it was just
easier to use InstantRails with it's preconfigured everything, then
put up ruby, the web server etc independently. YMMV.

Assaph