Showing posts with label jira. Show all posts
Showing posts with label jira. Show all posts

Thursday, April 7, 2011

JIRA instance restarter

Just a simple script I use to watch for JIRA process, in case if it dies the script would restart it automatically.  This can be used for whatever process.  Note: it's using ps awwx under Solaris.

#!/bin/sh


jira=$1

pid=`/usr/ucb/ps awwx | grep java | grep "$jira"  | awk {'print $1'}`

if [ "$pid" = "" ]
then
    pid=0
fi
if [ $pid -gt 1 ]

then
    echo $jira" - JIRA is running fine"
else
    echo $jira" - JIRA is not running, trying to restart... "
    echo $jira"bin/restart.sh"
    $jira"bin/restart.sh"
fi


----------------------------------------------------------------
few more JIRA house keeping daily scripts:


## lock-cleanup.sh

#!/bin/sh
JIRA_HOME=/opt/global/jira
if [ -f $JIRA_HOME/index/comments/write.lock ];
then
    rm $JIRA_HOME/index/comments/write.lock
fi
if [ -f $JIRA_HOME/index/issues/write.lock ];
then
    rm $JIRA_HOME/index/issues/write.lock
fi


----------------------------------------------------------------
## backup-cleanup.sh 
#!/bin/sh
JIRA_HOME=/opt/global/jira
DAYS=30
find $JIRA_HOME/backup/ -name "*.zip" -ctime +$DAYS -exec rm {} \;

Thursday, February 28, 2008

load balance & fail-over with tomcat using apache proxy_ajp_module proxy_balancer_module

In the past, we have been using mod_jk as the connector to front apache http server for tomcat, it does load balance and fail-over nicely. Now apache has modules such as proxy_ajp_module and proxy_balancer_module that would serve the same purpose, but with simpler configuration. Below is the VirtualHost config in apache httpd:
NameVirtualHost *:8080
<VirtualHost *:8080>

<Location /balancer-manager>
SetHandler balancer-manager
</Location>

<Proxy balancer://ajpCluster>
BalancerMember ajp://localhost:8109 route=jvm1
BalancerMember ajp://localhost:8209 route=jvm2
</Proxy>

ProxyPass /balancer-manager !
ProxyPass / balancer://ajpCluster/ stickysession=JSESSIONID nofailover=On
</VirtualHost>

On the tomcat end there are a few things needs to be changed in server.xml:

Uncomment the section where it defines the AJP connector and change the port number:
<!– Define an AJP 1.3 Connector on port 8009 –->
<Connector port=”8109″ enableLookups=”false” redirectPort=”18443″ protocol=”AJP/1.3″ />

This part I totally forgot which took me a while to realize that I did not define the jvmRoute name in tomcat. This would be appended to the JSESSIONID cookie so it knows which tomcat to route to:
<Engine name=”Catalina” defaultHost=”localhost” jvmRoute=”jvm1">

Now when you hit http://hostname:8080/ it hits the apache httpd server and it would route you to the least loaded tomcat that is up running.
http://hostname:8080/balancer-manager
would show you the status of the load balancer and tomcat servers.

I have tested this worked well with JIRA.