# Mongrel as a Windows Service (not running Rails)

**URL:** <https://www.ruby-forum.com/t/mongrel-as-a-windows-service-not-running-rails/160790>\
**Category:** Mongrel\
**Created:** [February 19, 2009, 6:24pm UTC](https://www.ruby-forum.com/t/mongrel-as-a-windows-service-not-running-rails/160790 "2009-02-19T18:24:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![danmcb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/13edae/32.png) [@danmcb](https://www.ruby-forum.com/u/danmcb)\
**Post date:** [February 19, 2009, 6:24pm UTC](https://www.ruby-forum.com/t/mongrel-as-a-windows-service-not-running-rails/160790/1 "2009-02-19T18:24:25Z")

</div>

Hi, I hope you can help me with this. I have implemented a simple web  
app on top of Mongrel and now I need to run it as a Windows Service. I  
explored the mongrel\_service gem and it looks like I will need an  
executable (.exe) for this. Is there a way to use the existing  
mongrel\_service.exe to run my own script?

Thanks in advance,

Daniel

---

<div class="post-metadata">

**Author:** ![danmcb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/13edae/32.png) [@danmcb](https://www.ruby-forum.com/u/danmcb)\
**Post date:** [February 19, 2009, 8:14pm UTC](https://www.ruby-forum.com/t/mongrel-as-a-windows-service-not-running-rails/160790/2 "2009-02-19T20:14:54Z")

</div>

On Thu, Feb 19, 2009 at 3:24 PM, Daniel M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Hi, I hope you can help me with this. I have implemented a simple web  
> app on top of Mongrel and now I need to run it as a Windows Service. I  
> explored the mongrel\_service gem and it looks like I will need an  
> executable (.exe) for this. Is there a way to use the existing  
> mongrel\_service.exe to run my own script?

mongrel\_service gem was implemented to work with Rails.

Inside the gem there is mongrel\_service.exe (inside bin), but that  
only works with mongrel\_rails script.

While your user case is a valid one, was not considered when developed.

You have a few options for your situation:

1. check mongrel\_service FreeBASIC code (which is the actual service)  
and implement your own variation.  
(willl take you some time)

2. look into options like svrany or firedaemon, which let you run  
console applications as services.

> Thanks in advance,

## Hope this helps,

## Luis L. AREA 17

Perfection in design is achieved not when there is nothing more to add,  
but rather when there is nothing more to take away.  
Antoine de Saint-Exupéry

---

<div class="post-metadata">

**Author:** ![danmcb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/13edae/32.png) [@danmcb](https://www.ruby-forum.com/u/danmcb)\
**Post date:** [February 20, 2009, 2:09pm UTC](https://www.ruby-forum.com/t/mongrel-as-a-windows-service-not-running-rails/160790/3 "2009-02-20T14:09:50Z")

</div>

> You have a few options for your situation:
> 
> 1. check mongrel\_service FreeBASIC code (which is the actual service)  
> and implement your own variation.  
> (willl take you some time)
> 
> 2. look into options like svrany or firedaemon, which let you run  
> console applications as services.

1. [GitHub - raggi/ruby\_service\_helper: A simple wrapper around win32-service to help with writing simple ruby based services · GitHub](http://github.com/raggi/ruby_service_helper/), and I recommend you  
also use [GitHub - raggi/rubyw\_helper: A handy helper for when stdio may be closed (e.g. under rubyw.exe on win32) · GitHub](http://github.com/raggi/rubyw_helper/), these work with win32-  
service-0.6.1. If you’re on a mingw build of ruby, you may need to gem  
install --platform=x86-mswin32-60 win32-service first, as gcc can’t  
deal with SEH.

The above provides something that’s relatively easy to prototype, but  
also still mostly debuggable:

[http://pastie.textmate.org/private/rsnvpy5eogjhicawttjgra](http://pastie.textmate.org/private/rsnvpy5eogjhicawttjgra) (untested)

HTH

---

<div class="post-metadata">

**Author:** ![danmcb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/13edae/32.png) [@danmcb](https://www.ruby-forum.com/u/danmcb)\
**Post date:** [February 20, 2009, 7:31pm UTC](https://www.ruby-forum.com/t/mongrel-as-a-windows-service-not-running-rails/160790/4 "2009-02-20T19:31:11Z")

</div>

Thanks guys for your suggestions. I will give them both a shot.

Daniel
