Howto - Running Redmine on mongrel as a service on windows
- by Achilles
I use Redmine on Mongrel as a project manager and I use a batch file (start-redmine.bat) to start the redmine in mongrel.
There are 2 issues with my setup:
1. I have a running IIS on the server that occupies the HTTP port (80)
2. The start-redmine.bat must be periodically checked to see if it's stopped after a restart that is caused by windows update service.
for the first issue, I have no choice but running mongrel on a port like 3000 and for the second issue I have to create a windows service that runs automatically in the background when the windows starts; and here comes the trouble!
There are at least 3 ways to run redmine as a service that I'm aware of; none of them can satisfy a performance view on this subject. you may read about them on
http://stackoverflow.com/questions/877943/how-to-configure-a-rails-app-redmine-to-run-as-a-service-on-windows
I tried them all. The easiest way to setup such a service is using mongrel_service approach; in 3 lines of command you're done. but the performance is significantly lower than running that batch file...
Now, I wanna show you my approach:
First suppose we have ruby installed into c:\ruby and we have issued the command gem install mongrel to get the mongrel gem installed into c:\ruby\bin
Also, suppose we have installed the Redmine into a folder like c:\redmine; and we have ruby's path (i.e. c:\ruby\bin) in our PATH environment variable.
Now Download and install the Windows NT Resource Kit Tools from microsoft website.
Open the command-line tool that comes with the Resource Kit (from start menu).
Use instsrv to install a dummy service called Redmine using the following command:
"[path-to-instsrv.exe]\instsrv" Redmine "[path-to-srvany.exe]\srvany.exe"
in my case (which is the default case) it was something like this:
"C:\Program Files\Windows Resource Kits\Tools\instsrv" Redmine "C:\Program Files\Windows Resource Kits\Tools\srvany.exe"
Now create the batch file. Open a notepad and paste these instructions into it and then save it as "c:\redmine\start-redmine.bat"
@echo off
cd c:\redmine\
mongrel_rails start -a 0.0.0.0 -p 3000 -e production
Now we need to configure that dummy service we had created before. WATCH OUT WHAT YOU'RE DOING FROM HERE ON, OR YOU MAY CORRUPT YOUR WINDOWS. To configure that service, open windows registry editor (Start - Run - regedit) and navigate to this node:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Redmine
Right-Click on "Redmine" node and using the context menu, create a new key called Parameters (New - Key)
Right-Click on "Parameters" and create a String Value property called Application. Do this again and create another String Value called AppParameters.
Now Double-click on "Application" and put cmd.exe into "Value data" section. Then Double-click on "AppParameters" and put /C "C:\redmine\start-redmine.bat" into Value data section.
We're done!
issue this command to run the redmine on mongrel as a service:
net start Redmine