# Using win32-service

**URL:** <https://www.ruby-forum.com/t/using-win32-service/150036>\
**Category:** Ruby\
**Created:** [October 2, 2008, 6:40pm UTC](https://www.ruby-forum.com/t/using-win32-service/150036 "2008-10-02T18:40:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahappydeath](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/54ee81/32.png) [@ahappydeath](https://www.ruby-forum.com/u/ahappydeath)\
**Post date:** [October 2, 2008, 6:40pm UTC](https://www.ruby-forum.com/t/using-win32-service/150036/1 "2008-10-02T18:40:30Z")

</div>

I am trying to create a windows service with Ruby. I have successfully  
created the service ( I can open up the services and see the service I  
created ) but when I try to start it I get the error message:  
“Could not start A Ruby Service(the name I  
gave it) on Local Computer.  
Error 1053: The service did not respond  
to the start or control request in a timely fashion”

I have the executable of the service pointed to the full path of “ruby  
c:\service.rb” and the contents of service.rb are:

require ‘win32/daemon’  
include Win32

class Daemon

def service\_main()  
while running?  
sleep 3  
File.open(“c:\test.log”, “a”) { |f| f.puts “service is running”}  
end  
end

def service\_stop  
exit!  
end

end

Daemon.mainloop

any ideas what I’m doing wrong?!!!

---

<div class="post-metadata">

**Author:** ![ahappydeath](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/54ee81/32.png) [@ahappydeath](https://www.ruby-forum.com/u/ahappydeath)\
**Post date:** [October 2, 2008, 7:20pm UTC](https://www.ruby-forum.com/t/using-win32-service/150036/2 "2008-10-02T19:20:55Z")

</div>

On Oct 2, 12:35 pm, ahappydeath [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> end
> 
> def service\_stop  
> exit!  
> end
> 
> end
> 
> Daemon.mainloop
> 
> any ideas what I’m doing wrong?!!!

also maybe i should mention… I just installed SP3

---

<div class="post-metadata">

**Author:** ![ahappydeath](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/54ee81/32.png) [@ahappydeath](https://www.ruby-forum.com/u/ahappydeath)\
**Post date:** [October 3, 2008, 1:27am UTC](https://www.ruby-forum.com/t/using-win32-service/150036/3 "2008-10-03T01:27:08Z")

</div>

ahappydeath wrote:

> On Oct 2, 12:35ï¿½pm, ahappydeath [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> also maybe i should mention… I just installed SP3

Did it work before you installed SP3?

---

<div class="post-metadata">

**Author:** ![ahappydeath](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/54ee81/32.png) [@ahappydeath](https://www.ruby-forum.com/u/ahappydeath)\
**Post date:** [October 3, 2008, 4:15pm UTC](https://www.ruby-forum.com/t/using-win32-service/150036/4 "2008-10-03T16:15:42Z")

</div>

On Oct 2, 7:25 pm, James D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ahappydeath wrote:
> 
> > On Oct 2, 12:35 pm, ahappydeath [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > also maybe i should mention… I just installed SP3
> 
> ## Did it work before you installed SP3?
> 
> Posted viahttp://www.ruby-forum.com/.

I should have been more clear… I never tried it on SP2.
