- Install java – https://kostadinovi.info/2019/11/12/install-oracle-java-8-on-debian-10/
- apt install tomcat9-user
- adduser user
- su – user
- mkdir -p /home/user/tomcats/common/bin
- cd tomcats
- tomcat9-instance-create test
- cp test/bin/* common/bin/
- vi common/bin/setenv.sh
- vi common/bin/env_vars.sh
- rm test/bin/*
- cd test/bin/
- ln -s ../../common/bin/startup.sh .
- ln -s ../../common/bin/shutdown.sh .
- vi /home/user/tomcats/test/conf/env_vars.sh
- vi /home/user/start_all_tomcats.sh
- vi /home/user/stop_all_tomcats.sh
- exit
- vi /etc/systemd/system/tomcats.service
- systemctl daemon-reload
- systemctl enable tomcats.service
Content of bin/setenv.sh
#!/bin/sh
#
. conf/env_vars.sh
. ../common/bin/env_vars.sh
export JAVA_OPTS="-Djava.security.egd=file:/dev/urandom -Djava.awt.headless=true -XX:+UseConcMarkSweepGC -Dfile.encoding=UTF-8 -server -Xms$XMS -Xmx$XMX -XX:PermSize=$PERM_SIZE -XX:MaxPermSize=$MAX_PERM_SIZE -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=$JMX_REMOTE_PORT -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Xrunjdwp:transport=dt_socket,address=$JMX_DEBUG_PORT,server=y,suspend=n"
export UMASK="0022"
Content of bin/env_vars.sh
#!/bin/sh
export CATALINA_HOME=/usr/share/tomcat9
export JDK_DIRS="/usr/lib/jvm/java-8-oracle"
export JAVA_HOME="/usr/lib/jvm/java-8-oracle"
Content of conf/env_vars.sh
#!/bin/sh
XMS=128m
XMX=2048m
JMX_REMOTE_PORT=8013
JMX_DEBUG_PORT=8014
Content of /home/user/start_all_tomcats.sh
#!/bin/sh
TOMCATS_ROOT_DIR="/home/user/tomcats"
cd $TOMCATS_ROOT_DIR
for i in $(ls | grep -v common); do
cd $i
bin/startup.sh
cd $TOMCATS_ROOT_DIR
done
Content of /home/user/stop_all_tomcats.sh
#!/bin/sh
TOMCATS_ROOT_DIR="/home/user/tomcats"
cd $TOMCATS_ROOT_DIR
for i in $(ls | grep -v common); do
cd $i
bin/shutdown.sh
cd $TOMCATS_ROOT_DIR
done
Content of /etc/systemd/system/tomcats.service
[Unit]
Description=Start all tomcats instancies
After=network.target
After=network-online.target
[Service]
User=user
Type=forking
ExecStart=/home/user/start_all_tomcats.sh
ExecStop=/home/user/stop_all_tomcats.sh
TimeoutSec=30
Restart=on-failure
RestartSec=30
StartLimitInterval=350
StartLimitBurst=10
[Install]
WantedBy=multi-user.target
Recent Comments