System « Intelligrape Groovy & Grails Blogs

Archive for the ‘ System ’ Category

Increasing the connection timeout between browser and the tomcat server

Posted by Tarun Pareek on December 21st, 2011

Hi,

There is a case stuck recently in my project where i need to increase the connection timeout between browser and the server, because of the reason before the response get completed server leave the connection which result in no response. My colleague Himanshu told me to change the setting in server.xml, which help in my purpose.

To increase the connection timeout on tomcat server follow the following steps :

1. Open the file server.xml residing in tomcat6/conf/.
2. You just need to set variable connectionTimeout in it to Value in Milliseconds.(i.e 1000 milliseconds = 1 second)

For example :

File : server.xml

<Connector port="8080" protocol="HTTP/1.1"  connectionTimeout="20000" URIEncoding="UTF-8"            redirectPort="8443" />

I thought it will be useful to share, hope it helps.
 

Thanks,
Tarun Pareek
tarun@intelligrape.com
http://in.linkedin.com/in/tarunpareek

  • Share/Bookmark
Posted in System

Speeding up Ubuntu

Posted by manoj on December 6th, 2011

Of-late my laptop has been highly responsive …. as responsive as a sloth can be… :P
I mean you wouldn’t be expecting an Intel i5 Processor with 4GB Ram and 500GB hard disk making you go for a coffee break every time you had to build or compile your code.
I am sure many of you must have experienced some form of lag with your Ubuntu (I am using 11.10… But I did experience some form of lag with 10x series also).

So in this blog post I’ll be discussing some ways that you can follow to speed up your Ubuntu

1). Disable StartUp Apps the Smarter Way

Now when I started up StartUp Applications on a my Ubuntu 11.10 installation, all you can see are a mere 5-6 apps. Mine Actually had a whole lot more that were run at start up but are simply not shown like Yakuake, Gwibber, Desktop Sharing Sevrer, Bluetooth Manager etc. Ubuntu 11.04 was somewhat better where you could see most apps but still not all that would be let loose at startup. Using the following commands, I was able to enable all apps running at startup to be shown here.

cd /etc/xdg/autostart
sudo sed --in-place 's/NoDisplay=true/NoDisplay=false/g' *.desktop

Once that was done, restarting Startup Applications now showed all the apps that were running at startup. Just read the description once and decide whether you want to keep it at startup or not.

Startup Applications shown Initially

Startup Applications Now Showing Full List

Startup Applications Now Showing Full List

rcconf is another tool that can be used but I found this method much more comprehensive and user friendly.

2). Swappiness is inversely proportional to Happiness :D

Swappiness is a property for the Linux Kernel that decides on how often to use the swap space. Most of the laptops today are equipped with 3-4 GB of Ram. So the principle of having double the swap space w.r.t to your memory size seems a bit outdated to me. Even though there was plenty of Ram available, my OS insisted on using the swap space, which in turn decreased responsiveness.
So I then moved on to change the swappiness value(Range:0-100, Default: 60)
Since I had a decent amount of RAM that could handle almost anything that was thrown at it, I decreased the swappiness quotient to 20.
To check the current swappiness value just type the following..

 cat /proc/sys/vm/swappiness 

Next to adjust the value swappiness value open

 sudo vim /etc/sysctl.conf 

Search for vm.swappiness and to change it to a desired value.If it is not present just add it to the end of the file. 10 is the figure that is mentioned on many forums, but I decided to play a bit safe and kept it a 20. Simply restart your system for the changes to take effect.

3). Reload Swap contents to Memory

Although I felt that decreasing the swappiness quotient did work for my computer, it is still possible that your computer swaps. This can hurt the multitasking performance of your system.
I found this script that you can use to to get the swap manually back into RAM.

err="not enough RAM to write swap back, nothing done"
mem=`free|grep Mem:|awk '{print $4}'`
swap=`free|grep Swap:|awk '{print $3}'`
test $mem -lt $swap && echo -e $err && exit 1
swapoff -a && swapon -a &&
exit 0

And place it at somwehere like

  /usr/local/sbin/swap2ram.sh 

Once you execute the script, it will transfer all your swap contents back to Memory, and free up your swap space. What it essentially does is turn off  swap space forcing everything back into RAM and turning it back on.

There are many more things that you can do to tweak up the speed of your computer, though I felt these 3 steps helped me a lot.
Hope this Helps :D

Manoj Mohan
manoj(at)intelligrape(dot)com
  • Share/Bookmark
Tags: , ,
Posted in Linux, System

How to delete all contents/objects of Amazon S3 bucket

Posted by Deepak Mittal on November 12th, 2011

If you have an S3 bucket with a huge number of files, and you want to delete the bucket, you need to empty the bucket first. If the bucket has a handful of files, then it is easy enough from the AWS interface, but if the bucket has a large number of files, then AWS interface is not an option; and you must use s3cmd or may be some other tool which allows this.


s3cmd is a command-line tool for manipulating S3 buckets and objects; and as you would expect, it does have a way to recursively delete all objects in a bucket.

s3cmd del –recursive –force <bucket_url>


What’s annoying is that S3 does not provide this capability natively. The above command probably simply lists all the objects first internally; and then makes a delete call on each object.


It took me a while to figure this out, because it does not seem to be documented, I found this in one of the comments on S3cmd page.

-Deepak


  • Share/Bookmark
Tags: ,
Posted in System

Installing CloneZilla on USB drive using Ubuntu.

Posted by Hitesh Bhatia on October 22nd, 2011

Clonezilla is a software that allows you to do bare metal backup and recovery.

To install Clonezilla we would need following Softwares, all of which are available freely.

  1. 7zip ( p7zip-full_9.04~dfsg.1-1_i386.deb)
  2. Tuxboot (tuxboot-linux-8 )
  3. Clonezilla (clonezilla-live-1.2.6-40-i686.iso)

Here are the steps to install CloneZilla

  1. Install 7zip required to install Tuxboot
    1. sudo dpkg -i p7zip-full_9.04~dfsg.1-1_i386.deb
    2. It would show something like
    3. (Reading database … 168886 files and directories currently installed.)
    4. Preparing to replace p7zip-full 9.04~dfsg.1-1 (using p7zip-full_9.04~dfsg.1-1_i386.deb) …
    5. Unpacking replacement p7zip-full …
    6. Setting up p7zip-full (9.04~dfsg.1-1) …
    7. Processing triggers for man-db …
    8. And Step 1 is done. 7Zip is Installed.

2. Run tuxboot

    1. By default tuxboot is not executable , change it permission to make it.
    2. chmod +x tuxboot-linux-8
    3. Run tuxboot with sudo permission
    4. sudo ./tuxboot-linux-8
    5. Set the values as shown in image

    Step 5 - Installing Clonezilla

    5.1. Select Diskimage – then in adjacent dropdown select iso
    5.2. And then select the clonezilla image ( the one you downloaded)
    5.3. Type – usb drive
    5.4. Press “OK” . And let it complete. It will ask to reboot afterwards , but you can also reboot later

3. And your clonezilla usb is ready now. You may now use it to clone systems.

_________________________________
Hitesh Bhatia
Mail,LinkedIn,Facebook,Twitter
_________________________________
  • Share/Bookmark
Posted in Linux, System

Increasing Productivity With The Right Hardware

Posted by Kushal Likhi on September 5th, 2011

Recently i upgraded my laptop to increase the productivity and to make it butterSmooth to work on even with the most demanding applications.
so here is what i did:

1) New High Speed Solid State Hard Drive

2) Increased RAM.

.

why SSD???

CPUs and GPUs thrive on being fed massive amounts of data in parallel, our hard drives aren’t so appreciative of our multitasking demands. And this is where SSDs truly shine.

SSD’s have high Read/Write speeds, which just makes the FILE I/O operations lightning fast.

It also helps in best utilization of your CPU, as it quenches the CPU’s thirst for data to be processed.

Why RAM??

I used to experience that if you run a grails application and open few instances of IDEA in your 64bit system, it used to go on swap, hence a couple of Gigs of extra RAM will not harm .. ;)

.

Hardware Aquired:

1) OCZ Vertex 2 40GB SSD – Rs.5000/-

2) 4GB DDR-3 Kingston Laptop RAM: Rs.1300/-

3) 2.5″ External SATA Casing: Rs.200/-

.

Installation:

its Petty simple, Just 2 steps procedure.

1) Remove the old Ram and HDD

2) Install the new Ones.. ;)

And the Extracted 500GB HDD from my Laptop is converted into an External USB 500GB HDD using the 2.5″ HDD Casing. Hurray… ;)

.

The Exact Steps are as follows:

1) Open the Laptop Back Cover

2) Remove HDD mounting screws

3) Remove OLD HDD

4) install the new SSD

5) Remove one existing 2GB RAM if no empty RAM slot present

6) Install new 4GB Ram

7) Close the Lid

8) All Done.. install requires OS/Softwares to your new SSD

Here are the illustrations:

.

P.S: My Laptop runs Like its been blessed with the alien technology.. :)

Regards

Kushal Likhi

  • Share/Bookmark
Posted in System

Setting System property from command line in grails

Posted by Vishal Sahu on August 24th, 2011

Hi,

In one of my recent grails project, i needed to set System property from command line while running the grails application.
I looked for it and found a simple solution to do so and found it worth sharing.


Suppose we want to set any property, say app.property=”propertyValue”, then the command to set the property in grails application would be:

  grails  -Dapp.property="propertyValue" run-app

Similarly to retrieve the value of System property, we use

String myPropertyValue= System.getProperty("app.property")

It helped me a lot..
Hope it helps


Vishal Sahu
vishal@intelligrape.com
www.intelligrape.com

  • Share/Bookmark
Tags: ,
Posted in Grails, Java tools, Linux, System

Using git diff feature on Github

Posted by Abhishek Tejpaul on June 7th, 2011

Hi Folks,

Recently I came across a cool way to compare differences between two branches, two tags, or between two commits on Github. Many a times in our project we have to thoroughly see what has been a specific change in the code base before we push it on our production branch.

Here is how you can view the differences in commits:

On the Github, go to the Source view of your project. You will see a link named ‘Branch List’. Once the page opens you can see a list of all the remote branches. Hit on the Compare button in front of any of the available branches to see the difference between two branches.

Now note the URL in the address bar. It should end with something like ‘…/compare/<x>…<y>’ where x and y are separated by three dots(…) and their values could be project’s branch names

Isn’t it good?

Well, Git’s (read about git diff) and Github’s goodness does not stop just here. Instead of branch names as the values of x and y, you can also put two different commit hashes or tag names to view the differences in the code-base. More so, the commit hashes do not have to belong to the same branch. So you can pretty much compare your code’s current snap-shot with any of its past snap-shot irrespective of branch or a tag or a commit hash.

Hope this helps someone.

Abhishek Tejpaul
abhishek@intelligrape.com
[IntelliGrape Software Pvt. Ltd.]

  • Share/Bookmark
Posted in System

Mounting an EBS Volume to an Instance and Soft Linking a Growing Directory to it

Posted by Vivek Krishna on May 5th, 2011

We were having a crisis on our project the other day. The VPS on which we were running our application had some issues with kernel and Tomcat, for that matter, any java process was running unpredictably. Tomcat would explode the WAR file once in a while and even if it did, it would just pause at “Deploying app.war” forever. After spending some time troubleshooting (we didn’t know that it was an issue with the kernel), we decided to move our infrastructure to Amazon EC2. We picked up an EBS based large instance, running Ubuntu and copied the setup from our production server to this new machine. The setup was a breeze, thanks to the scripts we already had in place for migrating our production setup to our QA machines for testing purposes.

However, we realized that Image Magick, which was being used from our application was not working as expected. In fact, it wasn’t working at all. We noticed that we were able to perform it as root, but not as any other user. The error which showed up was that there was lack of disk space. Static documents generated by our application were stored on the file system and it was meant to be an ever expanding directory. The EBS instance we had chosen had a capacity of just 8GB and about 6 GB of that was being occupied by the OS and the rest of our infrastructure. We decided to move this particular directory to a new EBS volume.

This could be accomplished smoothly, thanks to the ease of attaching a new EBS volume to an instance. We added a new volume and then, performed the following steps to move this particular expanding directory.


mke2fs -F -j /dev/sdh #This is to create an ext3 file system for the device attached at /dev/sdh

mkdir /path_to_new_file_system

mount /dev/sdh /path_to_new_file_system #mount the new file system at this directory

cp -r static_documents_location /path_to_new_file_system #Copy the files from the existing directory to the new directory

mv static_documents_location static_documents_location_backup #Backup the existing documents, just in case anything goes wrong

ln -s /path_to_new_file_system/static_documents_location static_documents_location #Create a soft link to refer to the new file location with the same name as the previous one

With these steps, we were good to go on the Amazon machine without even requiring a Server restart. We were expecting a downtime of at least 10 minutes but this happened so flawlessly.

Hope this helps someone.

  • Share/Bookmark
Posted in Database, Linux, System

Generating EAN-8 standard barcode using Barcode4J

Posted by Vishal Sahu on April 14th, 2011

Hi,

In one of my project i needed to generate EAN-8 standard bar-code for identifying the various products. I searched for various libraries available for generating bar-code and found a library to do so. The library i used for generating the bar-code is Barcode4J.
You can download it from here

Barcode4J is a flexible generator for barcodes written in Java. It’s free, available under the Apache License, version 2.0.
The bar-code generated with the help of of this library uses eight digit number hence EAN-8.

To generate bar-code image from this library is quite simple. Just put the barcode4j.jar in the lib folder of the application.


Code to generate image is:-

public File generateBarcode(Long codeDigits){
try {
      //'codeDigits' is the code for which we want to generate bar-code image
     EAN8Bean bean = new EAN8Bean();
     final int dpi = 150;
     bean.setModuleWidth(UnitConv.in2mm(1.0f / dpi));
     bean.setFontSize(2.0)
     bean.doQuietZone(true)
     File outputFile = new File(filepath) // existing file in the file system
     OutputStream out = new FileOutputStream(outputFile)

     // class to convert provided image into barcode image
     BitmapCanvasProvider canvas = new BitmapCanvasProvider(out, "image/jpeg", dpi,   BufferedImage.TYPE_BYTE_BINARY, false, 0)
     bean.generateBarcode(canvas, codeDigits)
     canvas.finish()
     return outputFile
}

So, here it takes a file from the file system and convert it into the required barcode image. Now, the user can simply display this image on the items.

In my case, i needed to generate a bar-code image for each product, so i create new file for every item, and stored it on the file system with unique name.

This works in my case.
Hope it helps


Cheers..!!!
Vishal Sahu
vishal@intelligrape.com

  • Share/Bookmark
Tags:

byobu: screen sessions in Linux

Posted by Salil on April 13th, 2011

This post is just to talk about Screen Sessions in Linux (esp. ubuntu) using command “byobu”.

 

What is Byobu?
Byobu is a Japanese term for decorative, multi-panel screens. As an open source project, Byobu is an elegant enhancement of plain GNU Screen.

 

Where can it be used?
You SSH to some remote machine and Run some commands (application, service, etc). Now you want to logout of ssh session. But want your screen turned-on, so that you just resume it, the next time you access the machine.

 

How to use it?
It’s as simple as 2 steps process.

Step 1: Enter command "byobu"
Step 2: Press F2 (to create a new screen)

here you go!

 

Now you are in a detachable screen session. Enter your commands. And once you done –

Press F6 (to detach the screen)

If you are already logged-into some remote machine (using ssh), now you can logout. And your screen will remain there.
Then, when you come back — you can resume your screen back by following commmand

$ screen -r

It’s good to read about other options (like, screen -x)

 

Your comments are always Welcome. Please post if you have any!

 

Cheers!
Salil Kalia
Salil [at] IntelliGrape [dot] com
Twitter LinkedIn

  • Share/Bookmark
Tags: , , ,
Posted in Linux, System