{"id":2778,"date":"2017-12-09T12:34:55","date_gmt":"2017-12-09T12:34:55","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/?p=2778"},"modified":"2020-01-09T06:59:00","modified_gmt":"2020-01-09T06:59:00","slug":"starting-multiple-instances-of-jboss-from-shell-script","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/starting-multiple-instances-of-jboss-from-shell-script\/","title":{"rendered":"Starting multiple instances of jboss from shell script"},"content":{"rendered":"<p><strong>tpatil created the topic: Starting multiple instances of jboss from shell script<\/strong><\/p>\n<p>For starting the multiple instances of jboss I have created the following 2 scripts.<\/p>\n<p>Please let me know if anybody has any other suggestions.<\/p>\n<p>JBstartall.sh will call JBstart.sh<br \/>\n[code language=&#8221;css&#8221;]<br \/>\n{code}<br \/>\n##############<br \/>\n#JBstartall.sh<br \/>\n##############<br \/>\n#!\/bin\/sh<\/p>\n<p>cluster=&#8221;node1:192.168.32.45,node2:192.168.32.46&#8243;<\/p>\n<p>for clust in ${cluster\/\/,\/ };<br \/>\ndo<br \/>\nHOST=`echo $clust |cut -f2 -d:`<br \/>\nNODE=`echo $clust |cut -f1 -d:`<br \/>\necho &#8220;Starting jboss $NODE on $HOST &#8230;..&#8221;<br \/>\n.\/JBstart.sh $NODE $HOST<br \/>\ndone<\/p>\n<p>date<br \/>\necho &#8220;JBstartall.sh complete&#8221;<br \/>\nexit 0<\/p>\n<p>#####<br \/>\n# EOS<br \/>\n#####<br \/>\n{code}<\/p>\n<p>and<\/p>\n<p>{code}<br \/>\n#!\/bin\/sh<br \/>\n### ====================================================================== ###<br \/>\n## ##<br \/>\n## JBoss Startup Script ##<br \/>\n## ARG1 =====&gt;Name of profile ##<br \/>\n## ARG2 =====&gt;Hostname\/IP address of node ##<br \/>\n### ====================================================================== ###<\/p>\n<p>JBOSSDIR=\/local\/sys\/jboss-eap-5.1\/jboss-as<br \/>\nTARGETDIR=$JBOSSDIR\/server\/$1<br \/>\nBINDHOST=$2<br \/>\nJMXUSER=admin<br \/>\nJMXPASS=admin<\/p>\n<p>echo &#8220;Starting jboss&#8230;&#8230;&#8230;..&#8221;<\/p>\n<p>rm \/tmp\/jboss.$1.start &gt; \/dev\/null<\/p>\n<p>$JBOSSDIR\/bin\/run.sh -c $1 -b $BINDHOST &gt; \/tmp\/jboss.$1.start 2&gt;&amp;1 &amp;<br \/>\npid=$!<\/p>\n<p>started=false<\/p>\n<p>for i in `seq 1 30` ; do<br \/>\nif ps -p $pid &gt; \/dev\/null ; then : ; else<br \/>\nbreak<br \/>\nfi<br \/>\nsleep 2<br \/>\nresult=&#8221;`$JBOSSDIR\/bin\/twiddle.sh -s $BINDHOST -u $JMXUSER -p $JMXPASS get &#8220;jboss.system:type=Server&#8221; Started &#8211;noprefix`&#8221;<br \/>\nif [ $? == 0 -a x&#8221;$result&#8221; == x&#8221;true&#8221; ] ; then<br \/>\nstarted=true<br \/>\nbreak<br \/>\nfi<br \/>\ndone<\/p>\n<p>if $started ; then<br \/>\necho $pid &gt;&gt; $TARGETDIR\/log\/jboss.pid<br \/>\necho &#8220;&#8230;&#8230;&#8230;Sucessfully Started&#8221;<br \/>\nexit 0<br \/>\nelif test i = 30 ; then<br \/>\necho &#8220;&#8230;&#8230;&#8230;&#8230;&#8230;Timed Out&#8221;<br \/>\nexit 1<br \/>\nelse<br \/>\necho &#8220;&#8230;&#8230;&#8230;&#8230;&#8230;Failed to Start&#8221;<br \/>\nexit 1<br \/>\nfi<\/p>\n<p>date<br \/>\necho &#8220;JBstart.sh complete&#8221;<br \/>\nexit 0<\/p>\n<p>#####<br \/>\n# EOS<br \/>\n#####<br \/>\n{code}<br \/>\n[\/code]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>tpatil created the topic: Starting multiple instances of jboss from shell script For starting the multiple instances of jboss I have created the following 2 scripts. Please let me know if anybody has any other suggestions. JBstartall.sh will call JBstart.sh [code language=&#8221;css&#8221;] {code} ############## #JBstartall.sh ############## #!\/bin\/sh cluster=&#8221;node1:192.168.32.45,node2:192.168.32.46&#8243; for clust in ${cluster\/\/,\/ }; do HOST=`echo&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","_joinchat":[],"footnotes":""},"categories":[2],"tags":[586],"class_list":["post-2778","post","type-post","status-publish","format-standard","hentry","category-uncategorised","tag-jboss"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/2778","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=2778"}],"version-history":[{"count":2,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/2778\/revisions"}],"predecessor-version":[{"id":8511,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/2778\/revisions\/8511"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=2778"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=2778"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=2778"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}