Embedded: Resin On Raspberry Pi

From Resin 4.0 Wiki

(Difference between revisions)
Jump to: navigation, search
Line 16: Line 16:
 
== Preface ==
 
== Preface ==
  
I'm going to assume you already have a working Raspberry Pi with Soft-float Raspbian Wheezy installed and updated, accessible via SSH.  If not, here are some links to help get you started:
+
I'm going to assume you already have a working Raspberry Pi with Soft-float Raspbian Wheezy installed, updated, and accessible via SSH.  If not, here are some links to help get you started:
  
 
* [http://www.raspberrypi.org/downloads Soft-float Debian Wheezy Download]
 
* [http://www.raspberrypi.org/downloads Soft-float Debian Wheezy Download]
Line 39: Line 39:
  
 
* Download Resin 4.0.35 or later from [http://www.caucho.com/download/ www.caucho.com].  4.0.35 was the first version to include changes necessary to compile Resin's native libraries on a Raspberry Pi
 
* Download Resin 4.0.35 or later from [http://www.caucho.com/download/ www.caucho.com].  4.0.35 was the first version to include changes necessary to compile Resin's native libraries on a Raspberry Pi
* We'll install Resin Pro, but Resin Open-Source will run fine also.  Resin Open-Source still has some native optimizations that need to be compiled.
+
* I'll install Resin Pro, but Resin Open-Source will run fine also.  Resin Open-Source still has some native optimizations that need to be compiled.
 
* Resin's native optimizations are always optional - it will run fine in pure Java mode with most features still available.
 
* Resin's native optimizations are always optional - it will run fine in pure Java mode with most features still available.
 +
  
 
1. Download, unzip, and install Resin.  There's nothing different here than any other Resin installation.  Just make sure Java can be found.  It must either be in the path or JAVA_HOME set as an environment variable.
 
1. Download, unzip, and install Resin.  There's nothing different here than any other Resin installation.  Just make sure Java can be found.  It must either be in the path or JAVA_HOME set as an environment variable.
Line 76: Line 77:
 
     lib      :  
 
     lib      :  
 
     libraries :  -lssl -lcrypto
 
     libraries :  -lssl -lcrypto
 +
 +
 +
2. Compile and install
  
 
  make
 
  make
Line 82: Line 86:
 
Resin will install to the standard directories /usr/local/share/resin, /var/resin, /etc/resin...   
 
Resin will install to the standard directories /usr/local/share/resin, /var/resin, /etc/resin...   
  
If you're on Resin Pro, now is the time to copy a license file to /etc/resin/licenses
+
 
 +
3. If you're on Resin Pro, now is the time to copy a license file to /etc/resin/licenses
  
 
  cp /home/pi/10101.license /etc/resin/licenses/
 
  cp /home/pi/10101.license /etc/resin/licenses/
  
There's really only 1 change required to run on Raspberry Pi.  On Oracle JDK you MUST modify /etc/resin/resin.properties to change the jvm_mode parameter, as Java will NOT run on Raspberry Pi in server mode!  Resin automatically uses -server unless this parameter is set:
+
 
 +
4. Configure JVM Mode
 +
 
 +
 
 +
''' Oracle JDK'''
 +
 
 +
There's 2 change required to run on Raspberry Pi and Oracle JDK:
 +
 
 +
 
 +
4.1 Modify /etc/resin/resin.properties to change the jvm_mode parameter, as Java will NOT run on Raspberry Pi in server mode!  Resin automatically uses -server unless this parameter is set:
  
 
  vi /etc/resin/resin.properties
 
  vi /etc/resin/resin.properties
Line 92: Line 106:
 
  jvm_mode    : -client
 
  jvm_mode    : -client
  
On OpenJDK, you have a couple choices.  -server implies -zero, the [http://openjdk.java.net/projects/zero/ Zero-Assembler Project VM]. There's also -jamvm, [http://jamvm.sourceforge.net/ JamVM]. Older version of OpenJDK had [http://www.cacaojvm.org/ Cacao JVM], but that appears to have been removed in recent releases and replace with [http://oss.readytalk.com/avian/ Avain VM], although with -avian I get missing library errors...
+
 
 +
4.2 Modify /etc/resin/cluster-default.xml, add a <watchdog-arg> parameter to set the Watchdog's JVM modeSearch for "jvm-mode" in the <server-default> section and put it after that.  Example:
 +
 
 +
vi /etc/resin/cluster-default.xml
 +
 
 +
    ...
 +
    <!-- defaults for each server, i.e. JVM -->
 +
    <server-default>
 +
      <jvm-arg-line>${jvm_args}</jvm-arg-line>
 +
      <jvm-mode>${jvm_mode}</jvm-mode>
 +
 +
      <watchdog-arg>-client</watchdog-arg>
 +
      ...
  
 
  root@raspberrypi:/# resinctl start
 
  root@raspberrypi:/# resinctl start
Line 98: Line 124:
 
  Server VM is only supported on ARMv7+ VFP
 
  Server VM is only supported on ARMv7+ VFP
  
If you're seeing the message above, you need to modify /etc/resin/resin.properties and set "jvm_mode    : -client".  Oracle JDK won't run in -server mode on a Raspberry Pi.
+
If you're seeing the message above, you need to modify resin.properties and cluster-default.xml as described above.  Oracle JDK won't run in -server mode on a Raspberry Pi.
 +
 
 +
 
 +
'''OpenJDK'''
 +
 
 +
 
 +
4.1  On OpenJDK, you have a couple choices.  -server implies -zero, the [http://openjdk.java.net/projects/zero/ Zero-Assembler Project VM].  There's also -jamvm, [http://jamvm.sourceforge.net/ JamVM].  Older version of OpenJDK had [http://www.cacaojvm.org/ Cacao JVM], but that appears to have been removed in recent releases and replaced with [http://oss.readytalk.com/avian/ Avain VM], although with -avian I get missing library errors...  See [Java On Raspberry Pi Performance] for testing results we did on the different VMs.
 +
 
 +
 
 +
5. Startup Resin!
 +
 
 +
root@raspberrypi:/# resinctl start
 +
Resin/4.0.35 launching watchdog at 127.0.0.1:6600
 +
Resin/4.0.35 started -server 'app-0' with watchdog at 127.0.0.1:6600
 +
 +
root@raspberrypi:/# ps -ef | grep java
 +
root      8558    1 25 15:16 pts/0    00:00:31 /usr/jdk1.7.0_10/bin/java -client -Dresin.watchdog=app-0 -Djava.util.logging.manager=com.caucho.log.LogManagerImpl
 +
-Djavax.management.builder.initial=com.caucho.jmx.MBeanServerBuilderImpl -Djava.awt.headless=true -Dresin.home=/usr/local/share/resin- 4.0.35/ -Dresin.root=/var/resin
 +
-Xrs -Xss256k -Xmx32m com.caucho.boot.WatchdogManager -root-directory /var/resin -conf /etc/resin/resin.xml -log-directory /var/log/resin start --log-directory /var/log/resin
 +
root      8609  8558 61 15:17 pts/0    00:00:57 /usr/jdk1.7.0_10/bin/java -Dresin.server=app-0 -Djava.util.logging.manager=com.caucho.log.LogManagerImpl
 +
-Djava.system.class.loader=com.caucho.loader.SystemClassLoader -Djava.endorsed.dirs=/usr/jdk1.7.0_10/jre/lib/endorsed:/usr/local/share/resin- 4.0.35//endorsed:/var/resin/endorsed
 +
-Djavax.management.builder.initial=com.caucho.jmx.MBeanServerBuilderImpl -Djava.awt.headless=true -Dresin.home=/usr/local/share/resin-4.0.35/ -Xss1m -Xmx256m
 +
-client com.caucho.server.resin.Resin --root-directory /var/resin -conf /etc/resin/resin.xml -server app-0  -socketwait 41515 -root-directory /var/resin -log-directory
 +
/var/log/resin start  --log-directory /var/log/resin
 +
root      8674  1978  0 15:18 pts/0    00:00:00 grep java
 +
 
 +
== Performance ==
 +
 
 +
At the moment, Resin performance on a Raspberry Pi is less than ideal, primarily attributed to disk access.  Even using a class 10 SD Card, disk reads are slow, and disk writes are really slow.  Resin does a lot of disk JAR file scanning and disk access to keep it's internal database synchronized (/var/resin/resin-data).
 +
 
 +
The worst performance hit is only during startup.  Once Resin is up, it's mostly the disk access and compiling JSPs that is slow.
 +
 
 +
'''Performance tips:'''
 +
 
 +
1. Use Oracle JDK.  It's [[Java On Raspberry Pi Performance|significantly faster than Open JDK]]
 +
 
 +
5. Remove unnecessary .jar files.
 +
 
 +
5. Use pre-expanded .war directory.  You may notice periods of blocking if you are using .war files, while Resin unzips and writes the files.
 +
 
 +
6. Use expand-preserve-fileset.  This tells Resin to keep compiled JSPs between webapp changes.
 +
 
 +
<web-app-deploy path="webapps"
 +
  expand-preserve-fileset="WEB-INF/work/**"/>

Revision as of 00:00, 14 February 2013

Embed-48.pngPie48.png

Contents

Resin on Raspberry Pi

We are currently in the early stages of modifying Resin to run on a Raspberry Pi.

Caucho Wiki Raspberry Pi Pages:

Resin on Raspberry Pi : Installation and Configuration

Preface

I'm going to assume you already have a working Raspberry Pi with Soft-float Raspbian Wheezy installed, updated, and accessible via SSH. If not, here are some links to help get you started:

I recommend you run "sudo apt-get update" and then "sudo apt-get upgrade". This will take something like 40 minutes, but it's good to have all the latest updates.

Java

If you're getting this error when running java, "error while loading shared libraries: libjli.so: cannot open shared object file: No such file or directory", it means you're trying to run Java on hard-float Rasbian. Get the soft-float version.

Resin

  • Download Resin 4.0.35 or later from www.caucho.com. 4.0.35 was the first version to include changes necessary to compile Resin's native libraries on a Raspberry Pi
  • I'll install Resin Pro, but Resin Open-Source will run fine also. Resin Open-Source still has some native optimizations that need to be compiled.
  • Resin's native optimizations are always optional - it will run fine in pure Java mode with most features still available.


1. Download, unzip, and install Resin. There's nothing different here than any other Resin installation. Just make sure Java can be found. It must either be in the path or JAVA_HOME set as an environment variable.

wget http://www.caucho.com/download/resin-pro-4.0.35.zip
unzip resin-pro-4.0.35.zip
cd resin-pro-4.0.35
./configure

You should get a configuration summary that looks like this:

Resin Configuration Summary:

 RESIN       : 4.0.35
   home      : /usr/local/share/resin-4.0.35
   root      : /var/resin
   conf      : /etc/resin
   log       : /var/log/resin
   plugins   : common resin_os resin resinssl
   init      : /etc/init.d/resin

 JAVA_HOME   : /usr/java/bin/..

 JNI         : 32-bit
   include       : -I/usr/java/bin/../include -I/usr/java/bin/../include/linux
   CFLAGS        : 
   cflags_shlib  : -fPIC
   ld_shlib      : gcc
   ldflags_shlib : -shared -fPIC
   libs_shlib    : 
   epoll() for keepalives

 OPENSSL     : OpenSSL 1.0.1c 10 May 2012
   include   : /usr/include
   lib       : 
   libraries :  -lssl -lcrypto


2. Compile and install

make
make install

Resin will install to the standard directories /usr/local/share/resin, /var/resin, /etc/resin...


3. If you're on Resin Pro, now is the time to copy a license file to /etc/resin/licenses

cp /home/pi/10101.license /etc/resin/licenses/


4. Configure JVM Mode


Oracle JDK

There's 2 change required to run on Raspberry Pi and Oracle JDK:


4.1 Modify /etc/resin/resin.properties to change the jvm_mode parameter, as Java will NOT run on Raspberry Pi in server mode! Resin automatically uses -server unless this parameter is set:

vi /etc/resin/resin.properties

jvm_mode    : -client


4.2 Modify /etc/resin/cluster-default.xml, add a <watchdog-arg> parameter to set the Watchdog's JVM mode. Search for "jvm-mode" in the <server-default> section and put it after that. Example:

vi /etc/resin/cluster-default.xml
   ...
   <server-default>
     <jvm-arg-line>${jvm_args}</jvm-arg-line>
     <jvm-mode>${jvm_mode}</jvm-mode>

     <watchdog-arg>-client</watchdog-arg>
     ...
root@raspberrypi:/# resinctl start
Error occurred during initialization of VM
Server VM is only supported on ARMv7+ VFP

If you're seeing the message above, you need to modify resin.properties and cluster-default.xml as described above. Oracle JDK won't run in -server mode on a Raspberry Pi.


OpenJDK


4.1 On OpenJDK, you have a couple choices. -server implies -zero, the Zero-Assembler Project VM. There's also -jamvm, JamVM. Older version of OpenJDK had Cacao JVM, but that appears to have been removed in recent releases and replaced with Avain VM, although with -avian I get missing library errors... See [Java On Raspberry Pi Performance] for testing results we did on the different VMs.


5. Startup Resin!

root@raspberrypi:/# resinctl start
Resin/4.0.35 launching watchdog at 127.0.0.1:6600
Resin/4.0.35 started -server 'app-0' with watchdog at 127.0.0.1:6600

root@raspberrypi:/# ps -ef | grep java
root      8558     1 25 15:16 pts/0    00:00:31 /usr/jdk1.7.0_10/bin/java -client -Dresin.watchdog=app-0 -Djava.util.logging.manager=com.caucho.log.LogManagerImpl 
-Djavax.management.builder.initial=com.caucho.jmx.MBeanServerBuilderImpl -Djava.awt.headless=true -Dresin.home=/usr/local/share/resin- 4.0.35/ -Dresin.root=/var/resin 
-Xrs -Xss256k -Xmx32m com.caucho.boot.WatchdogManager -root-directory /var/resin -conf /etc/resin/resin.xml -log-directory /var/log/resin start --log-directory /var/log/resin
root      8609  8558 61 15:17 pts/0    00:00:57 /usr/jdk1.7.0_10/bin/java -Dresin.server=app-0 -Djava.util.logging.manager=com.caucho.log.LogManagerImpl 
-Djava.system.class.loader=com.caucho.loader.SystemClassLoader -Djava.endorsed.dirs=/usr/jdk1.7.0_10/jre/lib/endorsed:/usr/local/share/resin- 4.0.35//endorsed:/var/resin/endorsed 
-Djavax.management.builder.initial=com.caucho.jmx.MBeanServerBuilderImpl -Djava.awt.headless=true -Dresin.home=/usr/local/share/resin-4.0.35/ -Xss1m -Xmx256m 
-client com.caucho.server.resin.Resin --root-directory /var/resin -conf /etc/resin/resin.xml -server app-0  -socketwait 41515 -root-directory /var/resin -log-directory 
/var/log/resin start  --log-directory /var/log/resin
root      8674  1978  0 15:18 pts/0    00:00:00 grep java

Performance

At the moment, Resin performance on a Raspberry Pi is less than ideal, primarily attributed to disk access. Even using a class 10 SD Card, disk reads are slow, and disk writes are really slow. Resin does a lot of disk JAR file scanning and disk access to keep it's internal database synchronized (/var/resin/resin-data).

The worst performance hit is only during startup. Once Resin is up, it's mostly the disk access and compiling JSPs that is slow.

Performance tips:

1. Use Oracle JDK. It's significantly faster than Open JDK

5. Remove unnecessary .jar files.

5. Use pre-expanded .war directory. You may notice periods of blocking if you are using .war files, while Resin unzips and writes the files.

6. Use expand-preserve-fileset. This tells Resin to keep compiled JSPs between webapp changes.

<web-app-deploy path="webapps"
 expand-preserve-fileset="WEB-INF/work/**"/>
Personal tools
TOOLBOX
LANGUAGES