We're using Ubuntu 16.04 LTS and want to use multiple Tomcat installations which should start at boot time. One of these Tomcats would host a Jenkins which will deploy a webapp onto the other tomcat and restart it.
To start the services, we added systemd service scripts. What we noticed is that when one tomcat is stopped or killed, the other is stopped as well.
We reduced this to two simple scripts that only use /usr/bin/yes:
[Unit] Description=A After=syslog.target network.target [Service] Type=simple ExecStart=/usr/bin/yes ExecStop=/bin/kill -15 $MAINPID User=tomcat8 Group=tomcat8 [Install] WantedBy=multi-user.target
[Unit] Description=B After=syslog.target network.target [Service] Type=simple ExecStart=/usr/bin/yes ExecStop=/bin/kill -15 $MAINPID User=tomcat8 Group=tomcat8 [Install] WantedBy=multi-user.target
When a service is killed (
kill -9), both services are gone afterwards.
- Why are both services killed? How can we prevent this?
- Is running more than one service under a single user discouraged, or is this good practice?
EDIT: For clarification - we did also try to do the same when launching the tomcats without systemd. In this instance, the behaviour was as expected: only the killed service was stopped while the other lived on.
EDIT2: The user is not a front-end user that logs in/out at all. It's purely a system user to restrict access of the services.