View Rahoul Baruah's profile on LinkedIn Basecamp project management and collaboration

The blog of Rahoul Baruah from 3hv Ltd

What's going on?

My name is Rahoul Baruah (aka Baz) and I'm a software developer in Leeds (England).

This is a log of things I've discovered while writing software in Ruby on Rails. In other words, geek stuff.

However, I've decided to put this blog on ice - I would ask you to check out my business blog here (or subscribe here).

02 December, 2005

Setting up WEBrick as a Windows Service




* Download the Windows 2003 Server Resource Kit from Microsoft and install it.
* Open a command prompt, move to the resource kit folder (normally C:\Program Files\Windows Resource Kit\bin ). Run “instsrv MyApp C:\Program Files\Windows Resource Kit\bin\srvany.exe”. This creates a new Windows service that is implemented by “srvany.exe”.
* Now we need to tell srvany that it should be using Ruby to implement the service. Open RegEdit and move to Local Machine/System/Current Control Set/Services/. Create a new Key (folder) called MyApp. Under here, create three new entries (Strings) called Application, AppParameters and AppDirectory. Application will be the path to the Ruby executable (normally C:\Ruby\bin\Rubyw.exe). AppParameters will be the command line passed to the Ruby executable (c:\MyApp\Script\Server —port 80 —environment=production) – this denotes that WEBrick should be run, using port 80 in production mode). AppDirectory is the folder in which the service should run (C:\MyApp) although this may not be necessary as all paths are provided in full above).
* Use the Control Panel/Administrative Tools/Services tool to adjust the credentials under which the service runs (using the “Log On” tab of the service properties) and then start the service and navigate to http://localhost/. Again, you should see the Ruby welcome page.

I have since discovered that XP/2003 are different to NT/2000/2000 Server when it comes to configuring srvany. When using NT/2000/2000 Server, instead of adding the AppParameter and Application keys to the MyApp key, create a new folder/key called "Parameters" and add AppParameter and Application there.

3 comments:

Anonymous said...

Thanks this was realy helpful

Baz said...

You're welcome.

Of course, the Mongrel server does all of this automatically.

spartacus727 said...

This article was a very big help for me also. I also had to learn how to install the mySQL add-on module, install rails in windows from scratch, and set up my dev. environment, so I added some info in my own tutorial:

http://jupiterit.com/wordpress/?page_id=36

That might help out some people needing more help.

eXTReMe Tracker