Topic: Cygwin help? - Windows with IIS, ISAPIRewrite, Mongrel, Pen
This is a description of a simple setup based on the "Integrate Rails
into an Existing IIS Web infrastructure using Mongrel" PDF at
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
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
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 and then downloaded the windows builds
of pen from 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
then edited the ISAPIRewrite httpd.ini file to proxy to port 4000
instead of 3000
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
In order for cygwin programs to run as a service, cygserver needs to be installed first. On win2k, I ran
cygserver-config in a cygwin console. This installed CYGWIN
cygserver as a service
Also, make sure you add -e "CYGWIN=server" to the parameters of
Details here: http://cygwin.com/cygwin-ug-net/using-c -cygserver
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
Does anyone have experience / solution for this?
I noticed that if I open the properties of the pen service in th Services panel, there are no parameters associated with them. Maybe I am missing something in the installation process -- a cygrunsrv catch?