Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cleaning up Jetty - Removing 'unnecessaries' things

Tags:

java

jetty

I'm used to use Jetty as my web container.

What I did on my install steps is get the original tar ball and cleanup some directories and files from it.

What I want to raise here, is:

What are you used to remove from Jetty to use on production/staging enviroments?

What I CHANGE on default jetty package:

  • REMOVE:
    • README.txt
    • pom.xml
    • javadoc/
    • examples/
    • /webapps/test*
    • /contexts/test*
    • /project-website
    • /resources/log4j.properties
  • CREATE:
    • work/

Questions:

  • I'm not breaking any license right?
  • Can I bring any drawback for my system (performance/stability) doing that?
  • Does anyone customize more than this on jetty?
  • Comments?
  • Questions?
  • Tips?

Related posts:

  • https://stackoverflow.com/questions/1486449/redistributing-jetty
like image 614
rafa.ferreira Avatar asked May 13 '11 17:05

rafa.ferreira


2 Answers

I'm not breaking any license right?

Correct.

Can I bring any drawback for my system (performance/stability) doing that?

The only drawback is that the Log4J properties file is useful for controlling how much (or how little) logging is performed. Disabling logging altogether results in smaller log files, conserving disk space. (Shouldn't be an issue with TB drives.) If the logging properties file cannot be found, an application might default to DEBUG or INFO levels, rather than ERROR levels. So, Log4J is useful to tell all applications to only log critical information.

Eliminating extraneous examples (the test suite) tightens security by exposing less system information. It can also save a bit of memory because the test webapps cannot get loaded into memory.

Does anyone customize more than this on jetty?

You can clean the webapps directory as follows:

cd /opt/jetty
rm -rf webapps
mkdir -p webapps/root
echo "<html><body></body></html>" > webapps/root/index.html

Restart Jetty.

like image 179
Dave Jarvis Avatar answered Oct 31 '22 04:10

Dave Jarvis


Here's one way of cleaning up Jetty (9.1.5).

tar -xzvf jetty-distribution-9.1.5.v20140505.tar.gz
# can rename 'jetty-distribution-9.1.5.v20140505' to 'jetty-9.1.5' or similar
cd jetty-distribution-9.1.5.v20140505
rm -rf VERSION.txt license-eplv10-aslv20.html notice.html start.d/jsp.ini resources/log4j.properties demo-base/
find -name README.TXT | xargs rm -fv

mv etc etc.bak              # keep a backup of etc/ and modules/, take whats necessary
mv modules modules.bak
mkdir etc modules work
mv modules.bak/.donotdelete modules.bak/deploy.mod modules.bak/ext.mod modules.bak/http.mod \
    modules.bak/logging.mod modules.bak/resources.mod modules.bak/security.mod modules.bak/server.mod modules.bak/servlet* \
    modules.bak/webapp.mod modules/
mv $(grep -h --color=none "etc.*.xml" modules/* | sed 's/etc/etc\.bak/g') etc/
mv etc.bak/jetty-started.xml etc.bak/jetty.conf etc/        # required for bin/jetty.sh
mv etc.bak/webdefault.xml etc/                              # required for web applications
                                                            # provides default deployment descriptor config for all apps
# rm -rf modules.bak/ etc.bak/                              # remove if not needed

sed -i '/^#/d; /^\s*$/d' start.ini start.d/http.ini         # clean if needed

vi start.ini start.d/http.ini                               # check and modify if needed
    start.ini: 'jetty.send.server.version=false', remove '--module=websocket'
    http.ini: 'jetty.port=9999'
vi modules/<whatever.mod>                                   # check and modify if needed
vi etc/jetty.xml # to prevent Jetty from showing context related information
    remove
        <Item>
            <New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/>
        </Item>
vi etc/jetty-logging.xml # suffix date with '-', instead of prefixing with '_'
    change
        <Arg><Property name="jetty.logs" default="./logs"/>/yyyy_mm_dd.stderrout.log</Arg>
        ...
        <Get id="ServerLogName" name="datedFilename"/>
    to
        <Arg><Property name="jetty.logs" default="./logs"/>/stderrout.log.yyyy_mm_dd</Arg>
        ...
        <Arg type="java.lang.String">yyyy-MM-dd</Arg>
        <Arg type="java.lang.String">HHmmssSSS</Arg>
        <Get id="ServerLogName" name="datedFilename"/>
vi etc/webdefault.xml # disable jsp support and modify other default settings
    remove or comment out <servlet> and <servlet-mapping> of JSP Servlet
    remove or comment out index.jsp from <welcome-file-list>
    set dirAllowed to false in default servlet
vi bin/jetty.sh # use $JETTY_BASE/logs instead of $JETTY_BASE as working directory
    change
        JETTY_RUN=$(findDirectory -w /var/run /usr/var/run $JETTY_BASE /tmp)
        JETTY_STATE=$JETTY_BASE/${NAME}.state
    to
        JETTY_RUN=$(findDirectory -w /var/run /usr/var/run $JETTY_BASE/logs $JETTY_BASE /tmp)
        JETTY_STATE=$JETTY_RUN/${NAME}.state
vi bin/jetty.sh # use $JETTY_HOME/work as default TMPDIR
    move following 
        TMPDIR=${TMPDIR:-/tmp}
    below 'JETTY_HOME=$PWD' and change
        TMPDIR=${TMPDIR:-"$JETTY_HOME"/work}

And the resulting structure.

jetty-distribution-9.1.5.v20140505
├── bin
│   └── jetty.sh
├── etc
│   ├── jetty-deploy.xml
│   ├── jetty-http.xml
│   ├── jetty-logging.xml
│   ├── jetty-started.xml
│   ├── jetty.conf
│   ├── jetty.xml
│   └── webdefault.xml
├── lib
│   └── <no change or keep only relevant>
├── logs
├── modules
│   ├── deploy.mod
│   ├── ext.mod
│   ├── http.mod
│   ├── logging.mod
│   ├── resources.mod
│   ├── security.mod
│   ├── server.mod
│   ├── servlet.mod
│   ├── servlets.mod
│   └── webapp.mod
├── resources
├── start.d
│   └── http.ini
├── start.ini
├── start.jar
├── webapps
└── work
like image 28
Sithsu Avatar answered Oct 31 '22 04:10

Sithsu