Cleaning up Jetty - Removing 'unnecessaries' things

前端 未结 3 1473
刺人心
刺人心 2021-02-20 02:58

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<

3条回答
  •  礼貌的吻别
    2021-02-20 03:41

    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/                                   # check and modify if needed
    vi etc/jetty.xml # to prevent Jetty from showing context related information
        remove
            
                
            
    vi etc/jetty-logging.xml # suffix date with '-', instead of prefixing with '_'
        change
            /yyyy_mm_dd.stderrout.log
            ...
            
        to
            /stderrout.log.yyyy_mm_dd
            ...
            yyyy-MM-dd
            HHmmssSSS
            
    vi etc/webdefault.xml # disable jsp support and modify other default settings
        remove or comment out  and  of JSP Servlet
        remove or comment out index.jsp from 
        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
    │   └── 
    ├── 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
    

提交回复
热议问题