1) For vanilla install on it is working fine.
service apiportal start
service apiportal stop
is working ok to stop the tomcat process.
2) So there must be something specific in the environment that is the cause.
Since the service was not working, in this environment the tomcat startup/shutdown scripts were being run directly (and run as root user) :
In the environment currently starting / stopping tomcat via scripts in : /opt/Deployments/lrs/server/bin
Are being used to start and stop the tomcat server.
We also see files in the tomcat deployment area are owned by ; root:root
This is not what we expect.
For the apiportal script used in service start and stop. It is in /etc/init.d/apiportal
Reviewing the script we see :
------ a) apiportal script will not stop tomcat, unless tomcat was started via the same apiportal script.
mainly this is because the script stores the <pid> of the running file in :
the pid to stop is stored here :
so unless started with the script, it won;t know which process to stop..
------ b) Run user
As we saw when looking at your environment, there were some files owned by l7portal and some files owned by root
# API Portal user and group
When started via the apiportal script, the run user will be l7portal and so files will be created with that user.
When started directly via scripts (as root user) new files and log files will be created / owned by root user.c) File ownership
Once some files (log files for example) are owned by root:root then it's not possible for l7portal user to modify them.
So there will be log files, but we also saw various deployment files as well that were owned by root user.
So once tomcat is run as root user - then it probably stops l7portal user from being able to start tomcat until the file permissions are restored. Since l7portal user will not have access to the files.