Forum: Ruby Ruby scripts as Win32-Service

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
William R. (Guest)
on 2006-02-18 05:14
(Received via mailing list)
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 R.
Patrick H. (Guest)
on 2006-02-18 05:36
(Received via mailing list)
On 2/17/06, William R. <removed_email_address@domain.invalid> wrote:
> 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 R.
>
>

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

pth
William R. (Guest)
on 2006-02-18 06:00
(Received via mailing list)
On 2/17/06, Patrick H. <removed_email_address@domain.invalid> 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 Z. (Guest)
on 2006-02-18 06:12
(Received via mailing list)
On 2/17/06, William R. <removed_email_address@domain.invalid> wrote:
> On 2/17/06, Patrick H. <removed_email_address@domain.invalid> 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.

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

-austin
Peter K. (Guest)
on 2006-02-18 09:25
(Received via mailing list)
>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

Regards,

Peter
Xavier N. (Guest)
on 2006-02-18 10:38
(Received via mailing list)
On Feb 18, 2006, at 8:25, Peter K. 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

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
Jeremy H. (Guest)
on 2006-02-18 10:59
(Received via mailing list)
On 2006-02-18, Patrick H. <removed_email_address@domain.invalid> wrote:
> On 2/17/06, William R. <removed_email_address@domain.invalid> wrote:
>> ... I'm stuck trying to figure out how to run the script as a
>> service.

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/pr...,
"srvany.exe is an additional Microsoft Windows application which
allows an executable to be ran as a service.".  Hope this helps.

Cheers,

Jeremy H.
Assaph M. (Guest)
on 2006-02-18 15:00
(Received via mailing list)
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
Xavier N. (Guest)
on 2006-02-18 15:45
(Received via mailing list)
On Feb 18, 2006, at 13:57, Assaph M. wrote:

> 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
Assaph M. (Guest)
on 2006-02-19 04:43
(Received via mailing list)
> 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
This topic is locked and can not be replied to.