Julian Joswig: IT Blog

Running Redmine on Windows Server 2012 R2 as Windows service

Written on 24. Jul 2016, 10:03

It is a bit complicated running Ruby, Rails and Redmine in conjunction with Microsoft Internet Information Services (IIS) on Windows. Luckily, Rails ships a build-in webserver called WEBRick that can be used to run Redmine on a Windows system, so you don't need Windows IIS then.

Purpose

It comes pretty handy running Redmine and WEBRick as a Windows service. This enables you to start, stop and re-start the service comfortably through the Windows Services (services.msc). In order to achieve this goal, we use the tool NSSM (the Non-Sucking Service Manager), which registers any executable file as a service to the Windows system.

Setup / Requirements

The setup is as follows: Installation
  1. Download NSSM (link see above) and extract it to any directory you like, e. g. C:\nssm-2.24
  2. Open a Command Prompt (cmd.exe) and change to the NSSM directory: [caption id="attachment_121" align="alignnone" width="678"]Command Prompt (cmd.exe) and NSSM directory Command Prompt (cmd.exe) and NSSM directory[/caption]
  3. Run NSSM through the command: nssm install <servicename> Make sure, that you are in the NSSM directory. You are free to choose any service name you like unless it is not in use.
  4. Install the service using NSSM: [caption id="attachment_123" align="alignnone" width="448"] NSSM (Non-Sucking Service Manager) and parameters to register Redmine as Service in Windows[/caption] As Path: point to your Ruby installation and to the Rails.bat, which is the executable file that runs by the rails command. As Startup directory: choose your redmine directory. As arguments, just use s. As Service name: this is prepopulated by the name you chose in step 3. The idea is that NSSM concatenates path and arguments and runs it in startup directory: C:\inetpub\wwwroot\redmine-3.1.0> C:\Ruby21-x64\bin\rails.bat s (meaning: running rails s in the Redmine directory, which starts WEBRick).
  5. Click on Install service to finish the registration.

Usage

Now you are able to start and stop your Redmine/WEBRick comfortably through Services in Windows. Run services.msc to control the service: [caption id="attachment_124" align="alignnone" width="966"]Services.msc console to start, stop and re-start Windows services. Services.msc console to start, stop and re-start Windows services.[/caption] As you can see, there is a service called redmine, which was registered by NSSM. Just start the service and browse to http://localhost:3000 (which is the default WEBRick configuration) to access your Redmine installation: [caption id="attachment_127" align="alignnone" width="1440"] Redmine default login webpage[/caption]

Conclusion

It is pretty comfortably running Redmine/Rails through NSSM as a Windows service. Please keep in mind, that this setup is not recommended to run productive or large-scale installations, since WEBRick (the Rails built-in webserver) is not optimized for this purpose. If you want to run Redmine for big setups, you should use Windows IIS as a webserver and integrate Redmine through FastCGI.

Sources:

Julian Joswig

Julian Joswig Facebook Julian Joswig LinkedIn Julian Joswig Twitter Julian Joswig XING

About this Blog

What is the content of this blog, you may ask? My name is Julian Joswig and I am a big fan of IT and technology (mainly Linux, servers, networks and all related topics). Sometimes I almost bite my teeth on difficult issues. But if I have found a solution, I want to share it with the world. Professionally, I work as a management consultant in Germany with a focus on IT and business.

Newest Articles:

Article Archive:

Twitter Timeline: