Directory structure analysis for online Java projects, and start-stop scripts

Source: Internet
Author: User
Tags stop script

In general, Java projects are eventually released in the form of jar or war


War is the Web project, the jar is the common Java project, can be launched directly, without any container


Fixed directory structure for general comparisons:

Project Name Demo

Demo/bin here is usually the start and stop script start.sh stop.sh

demo/conf System Configuration File

Demo/base War Project, put the war pack on this

demo/***

Demo/lib War project is not required, because the war project is built through MVN, the referenced jar package will be in the war package, if it is a jar project, you need this directory to store your jar package (if you can also play together by MVN, many words)

Demo/logs This is a must, the location where the log is stored

How do I configure log??

<appender name= "App-log-file" class= "Org.apache.log4j.DailyRollingFileAppender" ><param name= "FILE" value= "${log.dir.path}/normandy.log"/><layout class= "org.apache.log4j.PatternLayout" ><param name= " Conversionpattern "value="%d-%c-%-4r [%t]%-5p%x-%m%n "/></layout></appender>
<pre name= "code" class= "HTML" ><logger name= "App-log" additivity= "false" ><level value= "${log.level}"/ ><appender-ref ref= "App-log-file"/></logger>


That way, when you get more than logger name in your Java class, you can write the log to the Demo-log file.

Key analysis under the Demo/bin directory script:

env.sh

Export Java_home=/usr/*/jdkexport nginx_home=/usr/*/nginxexport jetty_home=/usr/*/jettyexport JETTY_PORT=****** Export App_install_home=****export app_log_dir_path=****export lang=zh_cn. UTF-8

The above is an example of the configuration of some variables, including Java,nggnx,jetty, project directory, log directory, etc.

start.sh

source./env.shjava_debug_opts= "-xdebug-xnoagent-xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n- dcom.sun.management.jmxremote.port=7788  -dcom.sun.management.jmxremote.authenticate=false- Dcom.sun.management.jmxremote.ssl=false "java_opts="-server-xmx512m-xms512m  -xss256k-xx:permsize=128m-xx: maxpermsize=128m  -XX:+USECONCMARKSWEEPGC-XX:+DISABLEEXPLICITGC  -xx:+useparnewgc-xx:+ cmsclassunloadingenabled-xx:+cmsparallelremarkenabled-xx:+usecmscompactatfullcollection-xx:+ USEFASTACCESSORMETHODS-XX:+USECMSINITIATINGOCCUPANCYONLY-XX:+USECOMPRESSEDOOPS-XX: Cmsinitiatingoccupancyfraction=70-xx:+heapdumponoutofmemoryerror-xx:survivorratio=8 "JAVA_OPTS=${JAVA_OPTS}"  * * * *-dlog_path= "${log_path} $SYS _echo" Starting......,please wait ... "${java_home}/bin/java ${java_debug_opts} $ {java_opts}-jar ${app_path}/*.jar ******

Here the java--opts is used to configure some Java boot parameters, and the project's system parameter-D parameter is obtained by System.getproperty

stop.sh

Pids= ' ${java_home}/bin/jps | grep **|awk ' {print $} ' for PID in $pids does   kill-9 $pid Done}
The loop will start the * * Process all killed, that is, stop

If it's a war bag project,

Ps-ef | grep Container | awk ' {Pring $} '

There are tomcat containers, jetty containers, etc.










Directory structure analysis for online Java projects, and start-stop scripts

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.