Tomcat не запускается в Systemctl Ubuntu, но да, с помощью startup.sh - PullRequest
0 голосов
/ 02 февраля 2019

Я не могу использовать systemctl с Ubuntu 18.04 для создания службы tomcat.

Когда tomcat запускается напрямую с помощью команды, все в порядке.

Но с сервисом:

  GNU nano 2.9.3 /etc/systemd/system/tomcat.service

[Unit]
Description=Apache Tomcat Web Application Container
After=network.target

[Service]
Type=forking

Environment=JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
Environment=CATALINA_PID=/opt/tomcat/latest/temp/tomcat.pid
Environment=CATALINA_HOME=/opt/tomcat/latest
Environment=CATALINA_BASE=/opt/tomcat/latest
Environment='CATALINA_OPTS=-Xms256M -Xmx256M -server -XX:+UseParallelGC'
Environment='JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom'

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

User=tomcat
Group=tomcat
UMask=0007

[Install]
WantedBy=multi-user.target

Я получаю следующий журнал в состоянии systemctl tomcat:

tomcat.service - Apache Tomcat Web Application Container
   Loaded: loaded (/etc/systemd/system/tomcat.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since Sat 2019-02-02 10:13:57 UTC; 8min ago
  Process: 10651 ExecStop=/opt/tomcat/latest/bin/shutdown.sh (code=exited, status=0/SUCCESS)
  Process: 10631 ExecStart=/opt/tomcat/latest/bin/startup.sh (code=exited, status=0/SUCCESS)
 Main PID: 10649 (code=exited, status=0/SUCCESS)

Feb 02 10:13:56 beloyal shutdown.sh[10651]:         at java.net.Socket.<init>(Socket.java:211)
Feb 02 10:13:56 beloyal shutdown.sh[10651]:         at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:513
Feb 02 10:13:56 beloyal shutdown.sh[10651]:         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Feb 02 10:13:56 beloyal shutdown.sh[10651]:         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorI
Feb 02 10:13:56 beloyal shutdown.sh[10651]:         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodA
Feb 02 10:13:56 beloyal shutdown.sh[10651]:         at java.lang.reflect.Method.invoke(Method.java:498)
Feb 02 10:13:56 beloyal shutdown.sh[10651]:         at org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:4
Feb 02 10:13:56 beloyal shutdown.sh[10651]:         at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:497)
Feb 02 10:13:56 beloyal shutdown.sh[10651]: The stop command failed. Attempting to signal the process to stop through OS
Feb 02 10:13:57 beloyal shutdown.sh[10651]: Tomcat stopped.

Команда pgrep -f tomcat return empty.

Команда journalctl -xe return:

Feb 02 11:40:29 beloyal systemd[1]: Starting Apache Tomcat Web Application Container...
-- Subject: Unit tomcat.service has begun start-up
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit tomcat.service has begun starting up.
Feb 02 11:40:29 beloyal startup.sh[14028]: Tomcat started.
Feb 02 11:40:29 beloyal sudo[14025]: pam_unix(sudo:session): session closed for user root
Feb 02 11:40:29 beloyal systemd[1]: Started Apache Tomcat Web Application Container.
-- Subject: Unit tomcat.service has finished start-up
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit tomcat.service has finished starting up.
--
-- The start-up result is RESULT.
Feb 02 11:40:30 beloyal shutdown.sh[14048]: Feb 02, 2019 11:40:30 AM org.apache.catalina.startup.Catalina stopServer
Feb 02 11:40:30 beloyal shutdown.sh[14048]: SEVERE: Could not contact [localhost:8005] (base port [8005] and offset [0]). Tomcat may not be running.
Feb 02 11:40:30 beloyal shutdown.sh[14048]: Feb 02, 2019 11:40:30 AM org.apache.catalina.startup.Catalina stopServer
Feb 02 11:40:30 beloyal shutdown.sh[14048]: SEVERE: Error stopping Catalina
Feb 02 11:40:30 beloyal shutdown.sh[14048]: java.net.ConnectException: Connection refused (Connection refused)
Feb 02 11:40:30 beloyal shutdown.sh[14048]:         at java.net.PlainSocketImpl.socketConnect(Native Method)
Feb 02 11:40:30 beloyal shutdown.sh[14048]:         at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
Feb 02 11:40:30 beloyal shutdown.sh[14048]:         at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
Feb 02 11:40:30 beloyal shutdown.sh[14048]:         at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
Feb 02 11:40:30 beloyal shutdown.sh[14048]:         at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
Feb 02 11:40:30 beloyal shutdown.sh[14048]:         at java.net.Socket.connect(Socket.java:589)
Feb 02 11:40:30 beloyal shutdown.sh[14048]:         at java.net.Socket.connect(Socket.java:538)
Feb 02 11:40:30 beloyal shutdown.sh[14048]:         at java.net.Socket.<init>(Socket.java:434)
Feb 02 11:40:30 beloyal shutdown.sh[14048]:         at java.net.Socket.<init>(Socket.java:211)
Feb 02 11:40:30 beloyal shutdown.sh[14048]:         at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:513)
Feb 02 11:40:30 beloyal shutdown.sh[14048]:         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Feb 02 11:40:30 beloyal shutdown.sh[14048]:         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
Feb 02 11:40:30 beloyal shutdown.sh[14048]:         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
Feb 02 11:40:30 beloyal shutdown.sh[14048]:         at java.lang.reflect.Method.invoke(Method.java:498)
Feb 02 11:40:30 beloyal shutdown.sh[14048]:         at org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:403)
Feb 02 11:40:30 beloyal shutdown.sh[14048]:         at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:497)
Feb 02 11:40:30 beloyal shutdown.sh[14048]: The stop command failed. Attempting to signal the process to stop through OS signal.
Feb 02 11:40:31 beloyal shutdown.sh[14048]: Tomcat stopped.
Feb 02 11:40:39 beloyal sudo[14100]:     root : TTY=pts/4 ; PWD=/opt/tomcat/apache-tomcat-9.0.14/bin ; USER=root ; COMMAND=/bin/systemctl status tomcat
Feb 02 11:40:39 beloyal sudo[14100]: pam_unix(sudo:session): session opened for user root by root(uid=0)
Feb 02 11:40:39 beloyal sudo[14100]: pam_unix(sudo:session): session closed for user root

Есть идеи?Возможно, что «Результатом запуска является РЕЗУЛЬТАТ».смущает systemd?

...