Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Howto - Running Redmine on mongrel as a service on windows

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 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

Edit: If you're gonna use the mail services of Redmine and you have an anti-virus like McAfee, make sure you told the anti-virus to allow ruby send emails or you won't get the mail service working.

like image 742
Achilles Avatar asked May 06 '10 14:05

Achilles


1 Answers

Thanks for the guide! By the way, if you're running Windows 2008, use the prerelease version of the mongrel service or else it won't work for you:

gem install mongrel_service --prerelease

http://groups.google.com/group/comp.lang.ruby/browse_thread/thread/1adf2a73c75c2884/38267c06198e282e?show_docid=38267c06198e282e

like image 142
TruMan1 Avatar answered Nov 13 '22 17:11

TruMan1