Akash Xavier RSS


About

Everything interesting that I come across in my life, I post it here.

Social
Dec
8th
Mon
permalink

Trick to quickly start rails server on windows

Since I use Windows XP, I often found it painful to cd to the app dir, then type in the command to start the rails server. I have multiple apps and this adds to the pain when I want to switch or even restart the server. So I just created a batch file that takes the app name/path and starts the server.

I have a folder called ‘apps’ which contains the folders of my all my apps. So I just placed this batch file myserver.bat into my ‘apps’ dir. And everytime I want to run something, I just enter the name of the app(which is the folder name of the app) or the full path to the app and the server starts. :)

@ECHO off

goto appstart

:appstart
set /p appname=Enter app name/path:
ECHO Starting %appname%…
ruby %appname%/script/server
goto appstart

Now just copy the above text and save it as myserver.bat or whatever.bat. And get going. When you use [Ctrl]+C to stop the rails server, then you get a prompt asking you choose whether to terminate the batch file, choose ‘No’ and the app follows a loop so you don’t have to even run this bat file again if you want to start a different rails app.