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.
58f117bf6458c7dd7bf84b9e27f73747?d=identicon&s=25 William Ramirez (mercan01)
on 2006-02-18 04: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 Ramirez
2c51fec8183a5d21c4e11b430beabb47?d=identicon&s=25 Patrick Hurley (Guest)
on 2006-02-18 04:36
(Received via mailing list)
On 2/17/06, William Ramirez <mercan01@gmail.com> 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 Ramirez
>
>

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

pth
58f117bf6458c7dd7bf84b9e27f73747?d=identicon&s=25 William Ramirez (mercan01)
on 2006-02-18 05:00
(Received via mailing list)
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.
31ab75f7ddda241830659630746cdd3a?d=identicon&s=25 Austin Ziegler (Guest)
on 2006-02-18 05:12
(Received via mailing list)
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.

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

-austin
F2749ed0e8e8c1a84e5ab57b45c61503?d=identicon&s=25 Peter Krantz (Guest)
on 2006-02-18 08: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
7223c62b7310e164eb79c740188abbda?d=identicon&s=25 Xavier Noria (Guest)
on 2006-02-18 09:38
(Received via mailing list)
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

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
7fd7ef91196768cae4e7ca215c8a0a8f?d=identicon&s=25 Jeremy Henty (Guest)
on 2006-02-18 09:59
(Received via mailing list)
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.

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 Henty
175e47c3d060e2635df0da9df0148580?d=identicon&s=25 Assaph Mehr (Guest)
on 2006-02-18 14: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
7223c62b7310e164eb79c740188abbda?d=identicon&s=25 Xavier Noria (Guest)
on 2006-02-18 14:45
(Received via mailing list)
On Feb 18, 2006, at 13:57, Assaph Mehr 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
175e47c3d060e2635df0da9df0148580?d=identicon&s=25 Assaph Mehr (Guest)
on 2006-02-19 03: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.