# Deploying on Windows with IIS, ISAPIRewrite, Mongrel, Pen an

**URL:** <https://www.ruby-forum.com/t/deploying-on-windows-with-iis-isapirewrite-mongrel-pen-an/89491>\
**Category:** Deployment\
**Created:** [March 20, 2007, 8:52pm UTC](https://www.ruby-forum.com/t/deploying-on-windows-with-iis-isapirewrite-mongrel-pen-an/89491 "2007-03-20T20:52:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![andre\_in\_LA](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/90db22/32.png) [@andre\_in\_LA](https://www.ruby-forum.com/u/andre_in_LA)\
**Post date:** [March 20, 2007, 8:52pm UTC](https://www.ruby-forum.com/t/deploying-on-windows-with-iis-isapirewrite-mongrel-pen-an/89491/1 "2007-03-20T20:52:35Z")

</div>

This is a description of a simple setup based on the “Integrate Rails  
into an Existing IIS Web infrastructure using Mongrel” PDF at  
[http://www.napcs.com/howto/rails/deploy/index.html](http://www.napcs.com/howto/rails/deploy/index.html)

I am having trouble with the last step: runnung Pen as a service in  
Cygwin environment on a win2k server.

First, the setup:

- Followed all steps from the PDF - installed ISAPIRewrite, created  
the httpd.ini file

[ISAPI\_Rewrite]  
RewriteProxy (.\*) http://localhost:3000$1 [I,U]

and saved it in the folder served by IIS.

Installed 2 mongrel instances as services on consequent ports (see  
[http://mongrel.rubyforge.org/docs/win32.html](http://mongrel.rubyforge.org/docs/win32.html) )

c:\>mongrel\_rails service::install -N myapp3000 -c c:\railsapp\_root -p  
3000 -e production  
c:\>mongrel\_rails service::install -N myapp3001 -c c:\railsapp\_root -p  
3001 -e production

Then started them using the services control panel.

At this point, the app runs OK but slowly with occasional timeouts.  
ISAPIRewrite proxies to the first mongrel instance at port 3000 and  
the second mongrel instance is never used.

I installed cygwin (if you do so, make sure to add cygrunsrv in the  
admin application list in the setup menu – it is not included by  
default) from [http://cygwin.com](http://cygwin.com) and then downloaded the windows builds  
of pen from [Pen](http://siag.nu/pen/) (click on the Download Source link and  
you’ll see pen-0.17.1.exe and pen-0.17.1a.exe in the list).

Then started cygwin and ran pen:

$ /cygdrive/c/path-to-pen/pen-0.17.1a.exe -H 4000 localhost:3000  
localhost:3001

then edited the ISAPIRewrite httpd.ini file to proxy to port 4000  
instead of 3000

[ISAPI\_Rewrite]  
RewriteProxy (.\*) http://localhost:4000$1 [I,U]

The rails app responded much better and remained online when I stopped  
the mongrel on port 3000 so pen was using both instances of mongrel.

The setup, however, is on a remote server and leaving an pen running  
in a cygwin terminal is not an option. I have to install and run pen  
as a service.

So, I stopped pen (the one running in the console) and installed it as  
a service using cygrunsrv (cygrunsrv readme is at  
[http://web.mit.edu/cygwin/cygwin\_v1.3.2/usr/doc/Cygwin/cygrunsrv.README](http://web.mit.edu/cygwin/cygwin_v1.3.2/usr/doc/Cygwin/cygrunsrv.README)  
)

In a cygwin console:

$cygrunsrv --install myapp\_pen4000\_3000-1 -p /cygdrive/c/path-to-pen/  
pen-0.17.1a.exe -a “-H 4000 localhost:3000 localhost:3001”

The service appeared in the Windows services panel. Unfortunately  
every attempt to run it ends with an error:

from the cygwin console:  
$ cygrunsrv --start myapp\_pen\_4000\_3000-1  
cygrunsrv: Error starting a service: QueryServiceStatus: Win32 error  
1062: The service has not been started.

Running it from the Services panel results in:  
Can not start myapp\_pen\_4000\_3000-1 on Local Computer.  
The service did not return an error. This could be an internal Windows  
error or an internal Service error. If the problem persists, contact  
your system administrator.

The event viewer shows:  
The description for Event ID ( 0 ) in Source ( pen ) cannot be found.  
The local computer may not have the necessary registry information or  
message DLL files to display messages from a remote computer. The  
following information is part of the event: pen: can’t bind local  
address.

Does anyone have experience / solution for this?

Thank you!

– Andre

---

<div class="post-metadata">

**Author:** ![andre\_in\_LA](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/90db22/32.png) [@andre\_in\_LA](https://www.ruby-forum.com/u/andre_in_LA)\
**Post date:** [March 20, 2007, 10:07pm UTC](https://www.ruby-forum.com/t/deploying-on-windows-with-iis-isapirewrite-mongrel-pen-an/89491/2 "2007-03-20T22:07:49Z")

</div>

One more thing, cygserver needs to be installed for cygwin programs to  
run as service. On win2k, run

cygserver-config in a cygwin console. This will install CYGWIN  
cygserver as a service

Also, make sure you add -e “CYGWIN=server” to the parameters of  
cygrunsrv

Details here:  
[http://cygwin.com/cygwin-ug-net/using-cygserver.html#what-is-cygserver](http://cygwin.com/cygwin-ug-net/using-cygserver.html#what-is-cygserver)

– Andre

---

<div class="post-metadata">

**Author:** ![andre\_in\_LA](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/90db22/32.png) [@andre\_in\_LA](https://www.ruby-forum.com/u/andre_in_LA)\
**Post date:** [March 30, 2007, 10:16am UTC](https://www.ruby-forum.com/t/deploying-on-windows-with-iis-isapirewrite-mongrel-pen-an/89491/3 "2007-03-30T10:16:36Z")

</div>

I remember seeing in the Deployment section of Agile, a caution  
explicitly stating “Dont deploy in Windows”. Has this since caution  
been removed?

Rajesh
