Recently I changed Apache Tomcat 7.x by Jetty 7.6.11 to test and production VMs. Incredibly, the start-up time passed of 8 minutes to +- 2.5 minutes, the same for memory usage during this process.
Both servers has the same behavior for my applications, however, the slow start-up time of Apache Tomcat 7.x complicates my life and all of clients :/ …In the last few weeks, I’ve need release several builds…this in the rush hour.
Problem…
For my Linux Mint (ubuntu-based) I can be install Jetty 7 directly from apt repositories, but for CentOS I’m need configure on the nail, and, its probably that two installations are not equal. So, I’ll need create a portable installation for Jetty works at two OS’s.
Downloading and moving
First, download Jetty 7 from Eclipse repositories here (you can choose by .zip, .tar, .tar.gz options) or using CI:
1 |
wget http://eclipse.c3sl.ufpr.br/jetty/stable-7/dist/jetty-distribution-7.6.11.v20130520.tar.gz |
After this, we can create all configurations ;)
Extract downloaded file:
1 |
tar -xzf jetty-distribution-7.6.11.v20130520.tar.gz |
Rename final folder (we don’t the version number : ))
1 |
mv jetty-distribution-7.6.11.v20130520 jetty7 |
Moving to /opt (you’ll maybe requires sudo privileges)
1 |
sudo mv jetty7 /opt/ |
.bashes and .confs
At jetty7/bin/ folder you have jetty.sh file, with all commands to correctly starts Jetty server instance, however, we have to configure some files with default configurations for Jetty instance. To this, create a configuration file at /etc/default/ called jetty:
1 |
sudo vim /etc/default/jetty |
Inside this file, you’ll put all yours configurations values, like this:
1 2 3 4 5 6 7 8 |
JAVA_HOME=/usr/java/jdk1.6.0_37 JAVA=$JAVA_HOME/bin/java JAVA_OPTIONS=" -server -Xms256m -Xmx512m -XX:+DisableExplicitGC" JETTY_HOME=/usr/java/jetty JETTY_USER=root JETTY_PORT=8080 JETTY_HOST=0.0.0.0 JETTY_LOGS=$JETTY_HOME/logs/ |
Save this file ‘Esc + :wq!’ (you know…)
Tip! You can use official Jetty docs to append additional configuration args to this file.
After create a symbolic link for jetty7/bin/jetty.sh at /etc/init.d/ folder.
1 |
sudo ln -s /opt/jetty7/bin/jetty.sh /etc/init.d/jetty |
Now, we can start the Jetty server using service command:
1 |
sudo service jetty {start|stop|restart|force-reload} |
Appendix
To realtime track Jetty logs, you can use tail -f command:
1 |
tail -f /opt/jetty7/logs/YYYY-mm-dd..stderrout.log |
To increase the max input parameters submitted to server, you’ll need add -Dorg.eclipse.jetty.server.Request.maxFormKeys=9000000 to /etc/default/jetty file. The final JAVA_OPTIONS will stay:
1 |
JAVA_OPTIONS=" -server -Xms256m -Xmx512m -XX:+DisableExplicitGC <span style="color: #ff9900;">-Dorg.eclipse.jetty.server.Request.maxFormKeys=9000000</span>" |
With you need replicate this installation, you can keep /etc/default/jetty inside of Jetty folder…like jetty7/bin/jetty or jetty7/configs/jetty and just create a symbolic links every new installation.
1 |
sudo ln -s /opt/jetty7/bin/jetty /etc/default/jetty |
Or also, create a bash file to make all this steps.
Reference
http://wiki.eclipse.org/Jetty/Howto/Configure_Jetty
http://wiki.eclipse.org/Jetty/Howto/Configure_Form_Size
http://wiki.eclipse.org/Jetty/Howto/How_to_serve_symbolically_linked_files
All comments are be welcome. Bye.