Monday, March 28, 2011

find process id for the port

Find port by following way

lsof -w -n -i tcp:8080
fuser -n tcp 8080

Now you have some integer value which is the process of the port
Now kill it by
kill -9 XXXX

Saturday, March 26, 2011

Debuging Technique with Ruby on Rails

There are multiple debug techniques are available with RoR,  Please use the
below techniques as much as you can,  while you do programming in RoR.

1. install ruby-debug
   then need to start application by ruby script/server --debugger
   And place word 'debugger' anywhere in your code and once you run your
application, it stops running from where you have placed 'debugger'. We
can say that debugger is the breakpoint

  Then you can use following commands
  n - move next line
  l - display the current line after the debugger
  c - continue
  You can also check the readme of the ruby-debug

2. You can use puts,exit etc.

3. You can use  logger.debug "The object is #{@object}" or  
  RAILS_DEFAULT_LOGGER.debug @object

4. In view, you can also use <%=debug @object %>

5. You can simultaneously check your log by running tail -f lod/development.log in the another terminal or you can also use tail -n log/development.log where n is any numeric number

6. We can use Exception Notifier plugin in our production environment so that we gets an notification mail if any error occurs on production

Contact Me for any help regarding rails/nodejs/php/mysql

Name

Email *

Message *