Saturday, January 18, 2014

Deploying a Play Framework Application on Raspberry Pi

It's simple to deploy a playframework application, just run 'play dist' and move the appname-version-SNAPSHOT.zip to your server, unzip and run the bin/appname script

However, the script's default memory allocation is 1GB, which more than a Raspberry Pi can support, and leads to the following error:

Error occurred during initialization of VM
Could not reserve enough space for object heap


BTW, I'm running Java 7 for ARM

java -version

java version "1.7.0_10"
Java(TM) SE Embedded Runtime Environment (build 1.7.0_10-b18, headless)
Java HotSpot(TM) Embedded Client VM (build 23.6-b04, mixed mode)

Reading through the script you'll see there are several options you can pass, including a mem option

bin/appname -h 

Usage:  [options]

  -h | -help         print this message
  -v | -verbose      this runner is chattier
  -d | -debug        set sbt log level to debug
  -mem      set memory options (default: , which is -Xms1024m -Xmx1024m -XX:MaxPermSize=256m -XX:ReservedCodeCacheSize=128m)
  -jvm-debug   Turn on JVM debugging, open at the given port.

  # java version (default: java from PATH, currently java version "1.7.0_10")
  -java-home          alternate JAVA_HOME

  # jvm options and output control
  JAVA_OPTS          environment variable, if unset uses ""
  -Dkey=val          pass -Dkey=val directly to the java runtime
  -J-X               pass option -X directly to the java runtime
                     (-J is stripped)

I changed the memory to 32mb and it started just fine

bin/appname -mem 32

bin/appname -mem 32

Play server process ID is 4356

[info] play - datasource [jdbc:postgresql://192.168.1.15:5432/postgres] bound to JNDI as DefaultDS
[info] play - database [default] connected at jdbc:postgresql://192.168.1.15:5432/postgres
[info] application - Application has started
[info] play - Starting application default Akka system.
[info] play - Application started (Prod)
[info] play - Listening for HTTP on /0.0.0.0:900

No comments:

Post a Comment