已设置CATALINA_PID,但指定的文件不存在

时间:2019-02-27 16:46:40

标签: ubuntu-16.04 tomcat8 tomcat9

我遵循此指南在Ubuntu 16.04.2 LTS Xenial(https://www.digitalocean.com/community/tutorials/how-to-install-apache-tomcat-8-on-ubuntu-16-04)上设置tomcat。

首先进行启动:

sudo systemctl start tomcat

并收到错误:

~$ sudo systemctl start tomcat
Job for tomcat.service failed because the control process exited with error code. See "systemctl status tomcat.service" and "journalctl -xe" for details.

journalctl -xe
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit tomcat.service has begun starting up.
Feb 27 15:23:42 76672.local startup.sh[20551]: Tomcat started.
Feb 27 15:23:42 76672.local shutdown.sh[20563]: $CATALINA_PID was set but the specified file does not exist. Is Tomcat running? Stop aborted.
Feb 27 15:23:42 76672.local systemd[1]: tomcat.service: Control process exited, code=exited status=1
Feb 27 15:23:42 76672.local systemd[1]: Failed to start Tomcat 9 servlet container.
-- Subject: Unit tomcat.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit tomcat.service has failed.
-- 
-- The result is failed.

CATALINA_PID应该位于目录/opt/tomcat/latest/temp/tomcat.pid

对于此目录/opt/tomcat以及所有子文件夹/文件,我有权对所有人进行处理:

~$ namei -l /opt/tomcat
f: /opt/tomcat
drwxr-xr-x root   root   /
drwxr-xr-x root   root   opt
drwxrwxrwx tomcat tomcat tomcat

有人可以指出我可能的解决方案吗?

UPD: 使用bin/startup.sh Tomcat成功启动。

1 个答案:

答案 0 :(得分:0)

在tomcat.service文件中使用CATALINA_PID时,请确保使用双引号内的路径。

Environment="CATALINA_PID=/opt/tomcat/latest/temp/tomcat.pid" 

像下面一样


[Unit]
Description=Tomcat 9 servlet container
After=network.target

[Service]
Type=forking

User=tomcat
Group=tomcat

Environment="/usr/lib/jvm/java-1.8.0-openjdk-amd64"
Environment="JAVA_OPTS=-Djava.security.egd=file:///dev/urandom -Djava.awt.headless=true"

Environment="CATALINA_BASE=/opt/tomcat/"
Environment="CATALINA_HOME=/opt/tomcat/"
Environment="CATALINA_PID=/opt/tomcat/temp/tomcat.pid"
Environment="CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC"

ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/opt/tomcat/bin/shutdown.sh

[Install]
WantedBy=multi-user.target

恭喜!