Setting up Self Healing Tomcat

System Administrator has to configure Critical services regularly. He/She also needs to monitor that services and if services stop then needs to start them. We can automate starting of service after failure using Daemontools/supervise. We can also use monit for same. In this note we will configure Daemontools to monitor Tomcat service and if Tomcat crashes, Daemontools will start it automatically.

Daemontools will make sure that tomcat service is running.

For Demo I have used OS -> CentOS-7 64bit &  Tomcat Version -> 8

Here are steps: Install Daemontools

$ git clone
$ cd /root/daemontools-rpm
$ wget
$ sudo yum -y install rpm-build redhat-rpm-config make gcc
$ cd /root/daemontools-rpm
$ ./
$ rpm -ivh /root/rpmbuild/RPMS/x86_64/daemontools-0.76-1.el7.x86_64.rpm
$ systemctl restart daemontools

Go to Tomcat Home. eg. /opt/tomcat

$ cd /opt/tomcat
$ cat >> /opt/tomcat/run <<'EOF'
exec 2>&1
export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-
export JAVA_OPTS="-Xms512M -Xmx2048M -XX:+UseParallelGC -server"
export TOMCAT_HOME=/opt/tomcat
exec setuidgid root ${TOMCAT_HOME}/bin/ run
$ chmod 755 /opt/tomcat/run

Configure Logging with multilog

$ mkdir /opt/tomcat/log
$ cat >> /opt/tomcat/log/run <<'EOF'
multilog t n1024 s104857600 /opt/tomcat/log/
$ chmod 755 /opt/tomcat/log/run

Create Symlink tomcat in /service

$ ln -s /opt/tomcat /service/tomcat

Start daemontools service

$ systemctl restart daemontools

Now you can check status

$ svstat /service/tomcat
$ svstat /service/tomcat/log


Neelesh Gurjar has written 122 articles