[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

another win32 service error

Junkone

2/25/2008 11:22:00 PM

Is there anything that my executable should do in order to be a
service. i have created services before with vb and have not
experienced issues. bat file is a simple one having this statemetn.
thin start -e production -p 3000

When i run it directly, it works. but i run it as part of the
servicem, the start up fails with this error


This is some service service failed to start due to the following
error:
The service did not respond to the start or control request in a
timely fashion.


My code for the service implementation is


require "win32/service"
include Win32


# Create a new service
Service.create('some_service', nil,
:service_type => Service::WIN32_OWN_PROCESS,
:description => 'A custom service I wrote just for fun',
:start_type => Service::AUTO_START,
:error_control => Service::ERROR_NORMAL,
:binary_path_name => 'E:\TradingTools\torontotrader
\startServer.bat',
:load_order_group => nil,
:dependencies => nil,
:service_start_name => 'LocalSystem',
:password => nil,
:display_name => 'This is some service'
)


1 Answer

Luis Lavena

2/26/2008 7:24:00 AM

0

On Feb 25, 9:22 pm, Junkone <junko...@gmail.com> wrote:
> Is there anything that my executable should do in order to be a
> service. i have created services before with vb and have not
> experienced issues. bat file is a simple one having this statemetn.
> thin start -e production -p 3000
>
> When i run it directly, it works. but i run it as part of the
> servicem, the start up fails with this error
>
> This is some service service failed to start due to the following
> error:
> The service did not respond to the start or control request in a
> timely fashion.
>
> My code for the service implementation is
>
> require "win32/service"
> include Win32
>
> # Create a new service
> Service.create('some_service', nil,
> :service_type => Service::WIN32_OWN_PROCESS,
> :description => 'A custom service I wrote just for fun',
> :start_type => Service::AUTO_START,
> :error_control => Service::ERROR_NORMAL,
> :binary_path_name => 'E:\TradingTools\torontotrader
> \startServer.bat',
> :load_order_group => nil,
> :dependencies => nil,
> :service_start_name => 'LocalSystem',
> :password => nil,
> :display_name => 'This is some service'
> )

First and most important: read the documentation.

What your script is actually doing is creating a service, a service
requires a special series of hooks to communitate with Service Control
Manager (SCM) and a batch file (.bat) cannot provide it.

Also, you cannot use a bat file directly in this case anyway, you need
to call cmd.exe and put the batch file as argument.

I'll suggest you take a look at the win32-service documentation and
samples:

win32utils docs (look at the win32-service section)
http://rubyforge.org/docman/?g...

ruby-services package at win32utils too:
http://rubyforge.org/frs/shownotes.php?group_id=85&relea...

That contains examples of implementing a RubyGems service or FastRI
services.

HTH,
--
Luis Lavena