Dubbo Official Shell startup script (with JVM parameters)

Source: Internet
Author: User

#!/bin/bashcd ' dirname $ ' bin_dir= ' pwd ' CD. Deploy_dir= ' pwd ' conf_dir= $DEPLOY _dir/confserver_name= ' sed '/dubbo.application.name/!d;s/.*=//' conf/ dubbo.properties | Tr-d ' \ r ' server_protocol= ' sed '/dubbo.protocol.name/!d;s/.*=//' conf/dubbo.properties | Tr-d ' \ r ' server_port= ' sed '/dubbo.protocol.port/!d;s/.*=//' conf/dubbo.properties | Tr-d ' \ r ' logs_file= ' sed '/dubbo.log4j.file/!d;s/.*=//' conf/dubbo.properties | Tr-d ' \ r ' if [-Z ' $SERVER _name]; Then server_name= ' hostname ' fipids= ' ps-f | grep java | grep "$CONF _dir" |awk ' {print $} ' if [-N ' $PIDS];    Then echo "Error:the $SERVER _name already started!" echo "PID: $PIDS" Exit 1fiif [-n "$SERVER _port"]; Then server_port_count= ' Netstat-tln | grep $SERVER _port | Wc-l ' If [$SERVER _port_count-gt 0];        Then echo "Error:the $SERVER _name Port $SERVER _port already used!" Exit 1 fifilogs_dir= "" If [-N "$LOGS _file"]; Then logs_dir= ' dirname $LOGS _file ' else logs_dir= $DEPLOY _dir/logsfiif [!-D $LOGS _dir]; Then mkdir $LOGS _dirfistdout_file= $LOGS _dir/stdout.loglib_dir= $DEPLOY _dir/liblib_jars= ' ls $LIB _dir|grep. Jar|awk ' { Print "' $LIB _dir '/" $} ' |tr "\ n" ":" ' java_opts= "-djava.awt.headless=true-djava.net.preferipv4stack=true" Java_debug _opts= "" If ["$" = "Debug"]; Then java_debug_opts= "-xdebug-xnoagent-djava.compiler=none-xrunjdwp:transport=dt_socket,address=8000,server=y, Suspend=n "fijava_jmx_opts=" "If [" $ "=" JMX "]; Then java_jmx_opts= "-dcom.sun.management.jmxremote.port=1099-dcom.sun.management.jmxremote.ssl=false- Dcom.sun.management.jmxremote.authenticate=false "fijava_mem_opts=" "bits= ' java-version 2>&1 | Grep-i 64-bit ' If [-N ' $BITS]; Then java_mem_opts= "-server-xmx2g-xms2g-xmn256m-xx:permsize=128m-xss256k-xx:+disableexplicitgc-xx:+useconcmarks weepgc-xx:+cmsparallelremarkenabled-xx:+usecmscompactatfullcollection-xx:largepagesizeinbytes=128m-xx:+ Usefastaccessormethods-xx:+usecmsinitiatingoccupancyonly-xx:cmsinitiatingoccupanCyfraction=70 "Else java_mem_opts="-SERVER-XMS1G-XMX1G-XX:PERMSIZE=128M-XX:SURVIVORRATIO=2-XX:+USEPARALLELGC "fie Cho-e "Starting the $SERVER _name ... \c" nohup java $JAVA _opts $JAVA _mem_opts $JAVA _debug_opts $JAVA _jmx_opts-classpath $C Onf_dir: $LIB _jars com.alibaba.dubbo.container.Main > $STDOUT _file 2>&1 &count=0while [$COUNT-lt 1]; Do echo-e ". \c" Sleep 1 if [-N "$SERVER _port"]; Then if ["$SERVER _protocol" = = "Dubbo"]; Then count= ' echo status | Nc-i 1 127.0.0.1 $SERVER _port | Grep-c OK ' else count= ' Netstat-an | grep $SERVER _port | Wc-l ' fi else count= ' ps-f | grep java | grep "$DEPLOY _dir" | awk ' {print $} ' | Wc-l ' fi if [$COUNT-gt 0]; Then break Fidoneecho "ok!" Pids= ' Ps-f | grep java | grep "$DEPLOY _dir" | awk ' {print $} ' echo ' PID: $PIDS "echo" STDOUT: $STDOUT _file "




Dubbo Official Shell startup script (with JVM parameters)

Related Article

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.