Here's an instruction guide (or should I say a documentation of my experience) to get a ruby-based web app running on a Windows server under Internet Information Services (IIS) version 7.5 and higher.
Specifically, "How to install Dashing on Windows Server with IIS 7.5+."
What's Dashing? you might ask. Well here's a quote from their website.
"Dashing is a Sinatra based framework that lets you build beautiful dashboards."
Now I know you're probably thinking Sinatra/Ruby on Windows under IIS?
Ouch, but why?
At work, we wanted to have a live dashboard with a data feed from our build server and our project management server (rallydev). We set up a Raspberry Pi with ubuntu-mate; we installed dashing with ease, and we pulled down a git repository with our customized work. We used RubyMine to develop locally on our windows laptop and committed the work to a remote repository, which the raspberry pi was able to access. This is the result:
It's current location overlooking the cube farm:
Have the dashboard accessible from each developer's computer without the need to physically walk by Big Brother. Have the site under IIS so that when the server crashes or reboots IIS restarts the site automatically, eliminating the need to log into the command prompt on the server and restart the dashing app.
Only windows servers were available for this installation, so I chose to install it on the server we were already choosing to use for internal tools that we have set up; such as a Nuget Server.
- go to RubyInstaller.org > Downloads
- Install version 2.2.x, which is more stable than the newer 2.3.x
this should add Ruby's bin to the PATH environment variable, to check, open a command prompt and type the following
it should respond with something like this:
ruby 2.2.4p230 (2015-12-16 revision 53155) [x64-mingw32]
- Install Ruby Installer Dev kit (on the same page as the regular ruby installer) this is needed for Dashing.
- The devkit runs an extractor, which will ask you for the permanent location for the devkit, I chose to install it under the ruby folder, which on the server looked like c:\Ruby22-x64\devkit
- Open a command prompt and CD to the devkit directory and run the following commands:
C:\Ruby22-x64\devkit>ruby dk.rb init
next run the following command from the same command prompt
This creates a config.yml file which lists the location of your ruby installation. It never seems to find the location for me; maybe it's my choice of devkit location. open the config.yml file located in the devkit directory and make sure last line is the location of your ruby install. For my instance it looks like this
C:\Ruby22-x64\devkit>ruby dk.rb install
- Install Dashing - you'll need to install the Dashing ruby gem so that you can create your starter instance of the site.
- With the command prompt still open type the following command:
C:\Ruby22-x64\devkit>gem install dashing
It doesn't matter where you run this command within the command prompt as 'gem' is a ruby command that is now accessible anywhere, and the 'gem' that is installed is installed globally under the Ruby installation directory.
- Create directory for your new dashboard: I use C:\websites\
- Here is a blog post about best practices for not using the default c:\inetpub\ directory.
- don't forget to give the user group "IIS_IUSRS", the "read & execute", "List folder contents", and "Read" persmissions on your new directory.
- Open command prompt and CD to this new directory.
- Run the following dashing command
C:\websites>dashing new sweet_dashboard_project
- CD into this new directory
- Run the following ruby gem command:
- Now lets tests that the website works outside of IIS, run the following command:
- Open a browser (this site wont work in IE) and navigate to localhost:3030
- Install HttpPlatformHandler v1.2 on IIS using WebPlatform Installer
- Here is a great blog post by Scott Hanselman about this IIS plugin - Announcing: Running Ruby on Rails on IIS8 (or anything else, really) with the new HttpPlatformHandler - Scott Hanselman
- And here is a video presentation on Channel 9 by Scott Hanselman
- Create the web.config file needed to run the website
- open the directory you created for the website e.g. C:\websites\sweet_dashboard_project\
- create a new file web.config
- edit the file to have the following:
<?xml version="1.0" encoding="UTF-8"?>
<handlers accessPolicy="Read, Script">
<add name="httpplatformhandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" requireAccess="Script" />
<httpPlatform stdoutLogEnabled="true" stdoutLogFile="c:\logs\dashing.log" startupTimeLimit="20" processPath="C:\Ruby22-x64\bin\ruby.exe"
arguments=""C:/Ruby22-x64/bin/dashing " start -p %HTTP_PLATFORM_PORT% -e production">
<environmentVariable name="HOME" value="C:\Users\<<%%YOURUSERNAME%%>>\" />
<environmentVariable name="EXECJS_RUNTIME" value="Node" />
In the config file please change the environment variable for HOME to your user directory (the user you installed ruby with) as ruby will need access to the .gem folder located there. On the C:\users\%yourusername%\.gem folder I also granted IIS_IUSRs user group, the same (execute, list and read) permissions as in step six to this folder.
Also, on the httpPlatform element I have the logging enabled for initial debugging, and I'm outputting the logs to a simple c:\logs\ location that the IIS_IUSRS has read write access to.
SETTINGS: To explain the settings in <httpPlatform></httpPlatform>, processPath points to the underlying process that will run your website, in this case it is the ruby executable that will run dashing, which is based on the Sinatra framework. You can point this at any executable that will handle http requests. The arguments setting is obviously intended to pass any argument the executable will need when IIS starts the process. There are also stdoutLogEnabled and stdoutLogFile setting which should be self explanatory, and there are more variables shown above and even more available, so please check the HttpPlatformHandler documentation online. Environment variables set in this section will be accessible to the running process, so you can provide them here as opposed to actually adding them to the servers environment variables which you may not have access to with permissions.
- Install NodeJS
- Go to Node.js website, download and run the installer.
The reason for installing NodeJS is to provide and alternate coffeescript compiler for ExecJS, I ran into encoding issues using the default cscript. and while using NodeJS is not ideal for this stack, the server I'm using is more than powerful enough, and it works flawlessly.
- After installing Node, you'll need to restart the server.
- Configure IIS for the new site.
- open Internet Information Services manager
- right-click on the server name and click add website.
- type in the name you want to give the website for Site Name
- Select the directory we setup as the physical path, this directory should have our web.config we created, sitting in it.
- If you have other websites under the default website then you'll want to pick another port name or add a host name to this site for IIS to differentiate the incoming http requests.
- I also set the application pool to No managed framework and Classic, as this site will not be attempting to access any .net framework components.
- You're finished!! Navigate to the url for your new site and you should see the sample. For more customizations, you'll have to read up on the Dashing documentation, possibly install RubyMine (which I recommend for easier development)