Play! Framework launch script with Plumbr integrated

Hey folks!

I discovered this new project, Plumbr, that helps you track your memory leaks.

The project seems great and very useful, so I decided to give it a try.

And since I'm using Play! Framework mainly for my java project, I wanted a way to simply launch Play! with Plumbr.

At first, Play! is very easy to integrate java options, just take a look at that run command : (supposing your play env is in /opt/play/{version}/ and plubmr at /opt/plubmr/beta/

/opt/play/1.2.4/play run /path/to/play/app/ -agentpath:/opt/plumbr/beta/linux/64/libplumbr.so -javaagent:/opt/plumbr/beta/plumbr.jar -noverify

So I did a little shell script that will perform this command for a better simplicity, here it is :

 

#!/bin/bash
#
# Shell script (BASH) used to launch a PLAY! Framework project with Plumbr
#
# For more information, go to :
# http://www.playframework.org/
# http://www.plumbr.eu/

#
# Installation
# Customize the script according to your need. You need to setup :
# - The path to PLAY! Framework service
# - The path to Plumbr
# --------------------------------------------------------------------
# This is a free shell script under GNU GPL version 3.0 or above
# Copyright (C) 2005 ReFlectiv project.
# Feedback/comment/suggestions : http://www.reflectiv.net/
# -------------------------------------------------------------------------

PLAY="/opt/play/1.2.4/play"
PLUMBR_PATH="/opt/plumbr/"

# -------------------------------------------------------------------------
# Now, don't touch anything, it's for your safety! :)
# -------------------------------------------------------------------------

if [ $1 ==  "" ]; then
        $1 = "."
fi

ARCH_BIT="32"
if [ `uname -m` == "x86_64" ]; then
        ARCH_BIT="64"
fi

ARCH_OS="linux"
if [ `uname -s` == "Darwin" ]; then
        ARCH_OS="mac"
fi

$PLAY run $1 -agentpath:$PLUMBR_PATH/$ARCH_OS/$ARCH_BIT/libplumbr.so -javaagent:$PLUMBR_PATH/plumbr.jar -noverify

Hope this helps!

If you find bugs, don't hesitate to comment them, I'll fix it!

Posted by Cyril Nicodème