Wednesday, January 26, 2011

How to make Redmine boot with Windows..

There are three ways we can configure a Rails application (redmine) to rub as a service on windows..


1. using webrick:

ref: http://www.redmine.org/boards/1/topics/4123

  • Download and install the Windows NT Resource Kit fromhttp://www.microsoft.com/downloads/details.aspx?familyid=9d467a69-57ff-4ae7-96ee-b18c4790cffd&displaylang=en

  • Create the service running:

    path\INSTSRV.EXE your_service_name path\SRVANY.EXE

    in my case path is:

    "C:\Program Files\Windows NT Resource Kit\INSTSRV.EXE" redmine_webrick "C:\Program Files\Windows NT Resource Kit\SRVANY.EXE"

    could be also C:\Program Files\Windows Resource Kits\Tools\.

  • Run regedit (Start -> Run -> regedit)

    • Add the following registry key if it's not already there:

      HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\your_service_name

    • Right click on this registry key and select New -> Key. Name it Parameters.

    • Add two values to the Parameters key. Right click on the parameters key, New -> String Value. Name it Application. Now create another one named AppParameters. Give them the following values:

      • Application: PathToRuby.exe, eg. C:\ruby\bin\Ruby.exe
      • AppParameters: C:\RUBYAPP\script\server -e production, where RUBYAPP is the directory that contains the redmine website.

      Example: C:\redmine\script\server -p 2000 -e production (-p indicates the port webrick will be listening to, and -e the environment used)

Now you can go to Administrative Tools -> Services. There you can start your service (the one with nameyour_service_name) and test whether or not it is working properly. It should be noted that the service will be marked as started prior to WEBrick finishing its boot procedure. You should give it 1min or so before trying to hit the service to verify that it is working correctly.

2. using mongrel:

ref: http://mongrel.rubyforge.org/wiki ref: http://mongrel.rubyforge.org/wiki/Win32

first install mongrel and mongrel_service gem

gem install mongrel

gem install mongrel_service

then create the service

mongrel_rails service::install -N redmine_mongrel -c c:\redmine -p 3000 -e production


Then goto RUN=>services.msc scroll down to the service redmine_mogrel and make the startup type automatic from manual.. do the same for all depend services needed by the application like Wampapache wampmysql and such..


3. using thin:

ref: http://code.macournoyer.com/thin/http://www.astarbe.com/es/trucos/windows/srvany_convierte_una_aplicacion_en_servicio

first install thin

(you'll need to install rack gem, if not already installed)

gem install rack

gem install thin

follow the same steps indicated for webrick, but add another value named "AppDirectory"

(this is needed in order to avoid using c:\ruby\bin\thin.bat If I just pointed to the bat file, I couldn't stop the service)

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\redmine_thin\Parameters

Application: c:\ruby\bin\ruby.exe AppDirectory: c:\redmine AppParameters: c:\ruby\bin\thin start -p 4000 -e production

--

you can control your service with the following commands

net start redmine_xxx

net stop redmine_xxx

sc config redmine_xxx start= auto

sc config redmine_xxx start= auto dependency= MySql

sc delete redmine_xxx


I completely recommend the 2nd method which is simple and safe..


Thanks stackoverflow

No comments: