6

Does anyone have experience with Microsoft's HTTP Platform Handler IIS extension yet? I'm following this great tutorial written a couple months ago and I've got Ruby on Rails installed:

C:\> ruby -v
ruby 2.1.5p273 (2014-11-13 revision 48405) [i386-mingw32]

C:\> rails -v
Rails 4.1.2

Rails starts and runs fine at port 3000 from a prompt:

C:\> rails s
=> Booting WEBrick
=> Rails 4.2.1 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2015-05-01 02:42:49] INFO WEBrick 1.3.1
[2015-05-01 02:42:49] INFO ruby 2.1.5 (2014-11-13) [i386-mingw32]
[2015-05-01 02:42:49] INFO WEBrick::HTTPServer#start: pid=9448 port=3000

This is great, but whenever I try to browse localhost/app (instead of localhost:3000), I get the dreaded "We're sorry, but something went wrong."

Here is my app's web.config file for IIS:

<?xml version="1.0"?>
<configuration>
    <system.webServer>      
      <handlers>
        <add
          name="httpplatformhandler"
          path="*"
          verb="*"
          modules="httpPlatformHandler"
          resourceType="Unspecified"
          requireAccess="Script" />
      </handlers>
      <httpPlatform
        stdoutLogEnabled="true"
        stdoutLogFile="rails.log"
        startupTimeLimit="200"
        processPath="c:\RailsInstaller\Ruby2.1.0\bin\ruby.exe"
        arguments="
          &quot;C:\Program Files\Windows Server\Bin\WebApps\Site\app\bin\rails&quot; server
          -p %HTTP_PLATFORM_PORT%
          -b 127.0.0.1">
      </httpPlatform>
    </system.webServer>
</configuration>

Event Viewer shows the HTTP Platform Handler initializing Ruby properly:

Process '10760' started successfully and is listening on port '2032'.

And Process Explorer shows w3wp.exe is running Ruby with the expected arguments:

ruby.exe 10760 c:\RailsInstaller\Ruby2.1.0\bin\ruby.exe "C:\Program Files\Windows Server\Bin\WebApps\Site\app\bin\rails" server -p 2032 -b 127.0.0.1

I can also see Rails is working from the rails.log file that HTTP Platform Handler generates:

=> Booting WEBrick
=> Rails 4.2.1 application starting in development on http://127.0.0.1:2032
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2015-05-02 12:23:44] INFO  WEBrick 1.3.1
[2015-05-02 12:23:44] INFO  ruby 2.1.5 (2014-11-13) [i386-mingw32]
[2015-05-02 12:23:45] INFO  WEBrick::HTTPServer#start: pid=10760 port=2032

Started GET "/app/" for [::1]:60449 at 2015-05-02 12:23:48 -0600

But I'm getting a 500 error and I can't figure out why. Here is the IIS log:

#Software: Microsoft Internet Information Services 8.5
#Version: 1.0
#Date: 2015-05-02 18:23:49
#Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) cs(Referer) sc-status sc-substatus sc-win32-status time-taken
2015-05-02 18:23:49 ::1 GET /app/ - 80 - ::1 Mozilla/5.0+(Windows+NT+6.3;+WOW64;+Trident/7.0;+rv:11.0)+like+Gecko - 500 0 0 146996

So there is the 500.0 error. Referencing this, I see that means a Module or ISAPI error occurred. But that's not super helpful, so I enabled Failed Request Tracing and here are the contents of that log:

-MODULE_SET_RESPONSE_ERROR_STATUS
ModuleName httpPlatformHandler
Notification EXECUTE_REQUEST_HANDLER
HttpStatus 500
HttpReason Internal Server Error
HttpSubStatus 0
ErrorCode The operation completed successfully.
          (0x0)
ConfigExceptionInfo

I've already run rake db:migrate, and I also copied sqlite3.exe, sqlite3.def, and sqlite3.dll to system32. Is there anywhere else I can look to find out what's causing this 500 error?

Community
  • 1
  • 1
crgolden
  • 4,332
  • 1
  • 22
  • 40
  • I don't have a direct answer for you, but I am successful in using IIS8 -> HTTP Platform Handler -> Ruby 2.1 -> Rails chain to run Redmine in IIS8. My configuration is basically the same as yours, however, I have added as a direct child of /configuration/system.webServer/httpPlatform. Perhaps that will help? – Chris Nielsen Jul 29 '15 at 21:37
  • @chris-nielsen, thanks so much for your comment! I have tried switching the environment in the environment variables, but that hasn't helped. I just did a clean install of Windows Server 2012 R2 and IIS, and am getting the same error. I have a feeling it may have to do with the App Pools. Did you do anything extra with your users in IIS? I can see ruby.exe starting in Process Explorer, but it immediately turns red and disappears. I can run `rake` and `rails` with no problem and the site renders correctly at port 3000 - just not under IIS... It's driving me crazy – crgolden Sep 30 '15 at 19:52
  • Have you change your app `config.ru` based on that tutorial ? – henggana Mar 17 '16 at 09:32
  • @henggana, thanks for asking. I had already configured the site to run with a relative root in the config.ru and it correctly resolves to that relative root when run on Rails locally and as a deployed application (just not on IIS locally). – crgolden Mar 22 '16 at 15:29
  • Did you find out what's killing the ruby processes? I have a similar problem, but don't even get to the 500 error. Just seeing ruby processes (with the correct arguments, and it works from the PowerShell) appearing and disappearing in the Process Explorer. – Jan Aug 11 '16 at 19:39

0 Answers0