summaryrefslogtreecommitdiffstats
path: root/base/server/tomcat/src
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2015-06-15 00:04:10 -0400
committerEndi S. Dewata <edewata@redhat.com>2015-06-16 17:51:38 -0400
commit44ec028366f5ea7c6e9c252ad4aac59055d1d121 (patch)
treebc07cb64a04cbab6aa6f247b156e87da49e2e093 /base/server/tomcat/src
parentff4d4f19cad6d2d99003cfb0d7219b82307f15fa (diff)
downloadpki-44ec028366f5ea7c6e9c252ad4aac59055d1d121.tar.gz
pki-44ec028366f5ea7c6e9c252ad4aac59055d1d121.tar.xz
pki-44ec028366f5ea7c6e9c252ad4aac59055d1d121.zip
Startup log message improvementes.
The PKIListener has been modified to verify that all subsystems are running and to show the command to enable the subsystem if it was disabled due to errors. https://fedorahosted.org/pki/ticket/1406
Diffstat (limited to 'base/server/tomcat/src')
-rw-r--r--base/server/tomcat/src/com/netscape/cms/tomcat/PKIListener.java100
1 files changed, 93 insertions, 7 deletions
diff --git a/base/server/tomcat/src/com/netscape/cms/tomcat/PKIListener.java b/base/server/tomcat/src/com/netscape/cms/tomcat/PKIListener.java
index abd88c1a6..5d1d0db23 100644
--- a/base/server/tomcat/src/com/netscape/cms/tomcat/PKIListener.java
+++ b/base/server/tomcat/src/com/netscape/cms/tomcat/PKIListener.java
@@ -1,7 +1,33 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2015 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+
package com.netscape.cms.tomcat;
+
+import java.io.File;
+
+import org.apache.catalina.Context;
+import org.apache.catalina.Engine;
+import org.apache.catalina.Host;
import org.apache.catalina.Lifecycle;
import org.apache.catalina.LifecycleEvent;
import org.apache.catalina.LifecycleListener;
+import org.apache.catalina.Server;
+import org.apache.catalina.Service;
import org.apache.commons.lang.StringUtils;
import com.redhat.nuxwdog.WatchdogClient;
@@ -12,22 +38,82 @@ public class PKIListener implements LifecycleListener {
@Override
public void lifecycleEvent(LifecycleEvent event) {
- String method = "NuxwdogReader:lifecycleEvent";
- if (event.getType().equals(Lifecycle.BEFORE_INIT_EVENT)) {
- System.out.println(method + ": before init event");
+
+ String type = event.getType();
+ System.out.println("PKIListener: " + event.getLifecycle().getClass().getName() + "[" + type + "]");
+
+ if (type.equals(Lifecycle.BEFORE_INIT_EVENT)) {
+
String wdPipeName = System.getenv("WD_PIPE_NAME");
if (StringUtils.isNotEmpty(wdPipeName)) {
startedByWD = true;
- System.out.println(method + ": Initializing the watchdog");
+ System.out.println("PKIListener: Initializing the watchdog");
WatchdogClient.init();
}
- } else if (event.getType().equals(Lifecycle.AFTER_START_EVENT)) {
- System.out.println(method + "After start event");
+
+ } else if (type.equals(Lifecycle.AFTER_START_EVENT)) {
+
if (startedByWD) {
- System.out.println(method + ": Sending endInit to the Watchdog");
+ System.out.println("PKIListener: Sending endInit to the Watchdog");
WatchdogClient.sendEndInit(0);
}
+
+ verifySubsystems((Server)event.getLifecycle());
}
}
+ public void verifySubsystems(Server server) {
+
+ Service service = server.findService("Catalina");
+ Engine engine = (Engine)service.getContainer();
+ String defaultHost = engine.getDefaultHost();
+ Host host = (Host)engine.findChild(defaultHost);
+
+ File instanceDir = new File(System.getProperty("catalina.base"));
+ String instanceName = instanceDir.getName();
+
+ for (File file : instanceDir.listFiles()) {
+
+ if (!file.isDirectory()) continue;
+
+ File csCfg = new File(file, "conf" + File.separator + "CS.cfg");
+ if (!csCfg.exists()) continue;
+
+ String subsystemName = file.getName();
+
+ File contextXml = new File(
+ instanceDir,
+ "conf" + File.separator + "Catalina" + File.separator +
+ defaultHost + File.separator + subsystemName + ".xml");
+
+ if (!contextXml.exists()) {
+
+ System.out.println("PKIListener: Subsystem " + subsystemName.toUpperCase() + " is disabled.");
+
+ String selftestsLog = "/var/log/pki/" + instanceName + "/" + subsystemName + "/selftests.log";
+ System.out.println("PKIListener: Check " + selftestsLog + " for possible errors.");
+
+ System.out.println("PKIListener: To enable the subsystem:");
+ System.out.println("PKIListener: pki-server subsystem-enable -i " + instanceName + " " + subsystemName);
+
+ continue;
+ }
+
+ Context context = (Context)host.findChild("/" + subsystemName);
+
+ if (context == null) {
+
+ System.out.println("PKIListener: " + "Subsystem " + subsystemName.toUpperCase() + " is not deployed.");
+
+ String catalinaLog = "/var/log/pki/" + instanceName + "/catalina.*.log";
+ System.out.println("PKIListener: Check " + catalinaLog);
+ System.out.println("PKIListener: and Tomcat's standard output and error for possible errors:");
+ System.out.println("PKIListener: journalctl -u pki-tomcatd@" + instanceName + ".service");
+
+ continue;
+ }
+
+ System.out.println("PKIListener: Subsystem " + subsystemName.toUpperCase() + " is running.");
+ }
+ }
}