Bamboo Data Center fails to stop showing error "Kill failed: $CATALINA_PID not set"
Platform Notice: Data Center - This article applies to Atlassian products on the Data Center platform.
Note that this knowledge base article was created for the Data Center version of the product. Data Center knowledge base articles for non-Data Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
The error message "Kill failed: $CATALINA_PID not set" is shown when attempting to stop the Bamboo process before it has fully started.
Environment
The solution has been validated in Bamboo 9.6 but may be applicable to other versions.
Diagnosis
When Bamboo is started, it typically creates a PID (Process ID) file to keep track of the running process. This PID file is referenced during stop operations to identify which process to terminate. If the process has not yet fully started and the PID file does not exist, stopping the process will fail, leading to the error message stating that the PID is not set.
/bamboo-install/atlassian-bamboo-9.6.1/bin » ./stop-bamboo.sh
Bamboo Data Center
Version : 9.6.1
If you encounter issues starting or stopping Bamboo Server, please see the Troubleshooting guide at https://confluence.atlassian.com/display/BAMBOO/Installing+and+upgrading+Bamboo
Using CATALINA_BASE: /bamboo-install/atlassian-bamboo-9.6.1
Using CATALINA_HOME: //bamboo-install/atlassian-bamboo-9.6.1
Using CATALINA_TMPDIR: /bamboo-install/atlassian-bamboo-9.6.1/temp
Using JRE_HOME: /opt/homebrew/Cellar/openjdk@11/11.0.24
Using CLASSPATH: /bamboo-install/atlassian-bamboo-9.6.1/bin/bootstrap.jar:/bamboo-install/atlassian-bamboo-9.6.1/bin/tomcat-juli.jar
Using CATALINA_OPTS: -Xms1024m -Xmx1024m -XX:+UseG1GC -Dsecure.tunnel.upstream.port=8093 --add-opens java.base/java.security=ALL-UNNAMED
NOTE: Picked up JDK_JAVA_OPTIONS: --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
Aug 09, 2024 2:53:07 PM org.apache.catalina.startup.Catalina stopServer
SEVERE: Could not contact [localhost:8007] (base port [8007] and offset [0]). Tomcat may not be running.
Aug 09, 2024 2:53:07 PM org.apache.catalina.startup.Catalina stopServer
SEVERE: Error stopping Catalina
java.net.ConnectException: Connection refused (Connection refused)
at java.base/java.net.PlainSocketImpl.socketConnect(Native Method)
at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:412)
at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:255)
at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:237)
at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.base/java.net.Socket.connect(Socket.java:609)
at java.base/java.net.Socket.connect(Socket.java:558)
at java.base/java.net.Socket.<init>(Socket.java:454)
at java.base/java.net.Socket.<init>(Socket.java:231)
at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:629)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:393)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:478)
Kill failed: $CATALINA_PID not set
Cause
The error occurs because the stop command is issued before the Bamboo process has had a chance to create the PID file. In other words, the startup sequence has not completed, and thus, the necessary environment variable ($CATALINA_PID) has not been set.
Solution
Wait for Full Startup: Ensure that Bamboo has fully started before attempting to stop it. You can check the startup logs to confirm that the process is running and the PID file has been created.