# Another win32 service error

**URL:** <https://www.ruby-forum.com/t/another-win32-service-error/186776>\
**Category:** Ruby\
**Created:** [February 26, 2008, 12:25am UTC](https://www.ruby-forum.com/t/another-win32-service-error/186776 "2008-02-26T00:25:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [February 26, 2008, 12:25am UTC](https://www.ruby-forum.com/t/another-win32-service-error/186776/1 "2008-02-26T00:25:51Z")

</div>

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’  
)

---

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [February 26, 2008, 8:26am UTC](https://www.ruby-forum.com/t/another-win32-service-error/186776/2 "2008-02-26T08:26:11Z")

</div>

On Feb 25, 9:22 pm, Junkone [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> The service did not respond to the start or control request in a  
> :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/?group\_id=85](http://rubyforge.org/docman/?group_id=85)

ruby-services package at win32utils too:  
[http://rubyforge.org/frs/shownotes.php?group\_id=85&release\_id=8222](http://rubyforge.org/frs/shownotes.php?group_id=85&release_id=8222)

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

HTH,
