idok-commit AT lists.psi.ch
Subject: Commit emails of the iDok project
List archive
[idok-commit] idok commit r680 - in branches/opensource: java/ch/psi/dms/service/server/admin sites/psi/java/ch/psi/dms/psi/service/server/admin sites/psi/java/ch/psi/dms/service/server/admin
Chronological Thread
- From: "Apache" <apache AT savannah.psi.ch>
- To: idok-commit AT lists.psi.ch
- Subject: [idok-commit] idok commit r680 - in branches/opensource: java/ch/psi/dms/service/server/admin sites/psi/java/ch/psi/dms/psi/service/server/admin sites/psi/java/ch/psi/dms/service/server/admin
- Date: Fri, 18 Jan 2008 12:16:12 +0100
- List-archive: <https://lists.web.psi.ch/pipermail/idok-commit/>
- List-id: Commit emails of the iDok project <idok-commit.lists.psi.ch>
Author: geus AT PSI.CH
Date: Fri Jan 18 12:16:12 2008
New Revision: 680
Log:
Implemented configurable method how to restart the Apache webserver and
renamed ApacheConfWriter classes and interface to ApacheHandler
Added:
branches/opensource/java/ch/psi/dms/service/server/admin/ApacheHandler.java
- copied, changed from r676,
/branches/opensource/java/ch/psi/dms/service/server/admin/ApacheConfWriter.java
branches/opensource/java/ch/psi/dms/service/server/admin/SimpleApacheHandler.java
- copied, changed from r676,
/branches/opensource/java/ch/psi/dms/service/server/admin/SimpleApacheConfWriter.java
branches/opensource/sites/psi/java/ch/psi/dms/psi/service/server/admin/PSIApacheHandler.java
- copied, changed from r677,
/branches/opensource/sites/psi/java/ch/psi/dms/psi/service/server/admin/PSIApacheConfWriter.java
Removed:
branches/opensource/java/ch/psi/dms/service/server/admin/ApacheConfWriter.java
branches/opensource/java/ch/psi/dms/service/server/admin/SimpleApacheConfWriter.java
branches/opensource/sites/psi/java/ch/psi/dms/psi/service/server/admin/PSIApacheConfWriter.java
branches/opensource/sites/psi/java/ch/psi/dms/service/server/admin/PSIApacheConfWriter.java
Modified:
branches/opensource/java/ch/psi/dms/service/server/admin/ApacheConfUpdaterThread.java
Modified:
branches/opensource/java/ch/psi/dms/service/server/admin/ApacheConfUpdaterThread.java
==============================================================================
---
branches/opensource/java/ch/psi/dms/service/server/admin/ApacheConfUpdaterThread.java
(original)
+++
branches/opensource/java/ch/psi/dms/service/server/admin/ApacheConfUpdaterThread.java
Fri Jan 18 12:16:12 2008
@@ -39,16 +39,18 @@
* Object that is responsible for generating the content of the
* configuration files
*/
- private ApacheConfWriter apacheConf_;
+ private ApacheHandler apacheConf_;
public ApacheConfUpdaterThread(PermissionAdapter permissionAdapter) {
permissionAdapter_ = permissionAdapter;
String apacheConfWriterClassName = System.getProperty(
- "ch.psi.dms.service.apacheConfWriter",
- "ch.psi.dms.service.server.admin.SimpleApacheConfWriter");
+ "ch.psi.dms.service.apacheConfWriter");
try {
- apacheConf_ = (ApacheConfWriter) Class.forName(
- apacheConfWriterClassName).newInstance();
+ if (apacheConfWriterClassName == null)
+ apacheConf_ = new SimpleApacheHandler();
+ else
+ apacheConf_ = (ApacheHandler) Class.forName(
+ apacheConfWriterClassName).newInstance();
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
@@ -211,14 +213,8 @@
*/
private void reloadApache() throws DmsException {
// Reload Apache configuration
- logger_.warning("Restarting httpd");
- int status = Admin.runShellCommand(new String[] {
"/etc/init.d/httpd",
- "graceful" }, null);
- if (status != 0) {
- throw new DmsException(ErrorType.INTERNAL, null,
- "Could not create new repository",
- "Error when reloading Apache configuration");
- }
+ logger_.warning("Restarting Apache webserver");
+ apacheConf_.restartApache();
}
}
Copied:
branches/opensource/java/ch/psi/dms/service/server/admin/ApacheHandler.java
(from r676,
/branches/opensource/java/ch/psi/dms/service/server/admin/ApacheConfWriter.java)
==============================================================================
---
/branches/opensource/java/ch/psi/dms/service/server/admin/ApacheConfWriter.java
(original)
+++
branches/opensource/java/ch/psi/dms/service/server/admin/ApacheHandler.java
Fri Jan 18 12:16:12 2008
@@ -9,7 +9,7 @@
/**
* Write per repository Apache configuration files
*/
-public interface ApacheConfWriter {
+public interface ApacheHandler {
/**
* Write the content of the per repository Apache *.conf file
@@ -43,4 +43,10 @@
Map<String, Map<String, Set<String>>> svnAccessInfo, Writer
writer)
throws DmsException;
+ /**
+ * Restart the Apache webserver to activate changes in configuration
files.
+ *
+ * The restart should be done as gracefully as possible.
+ */
+ void restartApache() throws DmsException;
}
Copied:
branches/opensource/java/ch/psi/dms/service/server/admin/SimpleApacheHandler.java
(from r676,
/branches/opensource/java/ch/psi/dms/service/server/admin/SimpleApacheConfWriter.java)
==============================================================================
---
/branches/opensource/java/ch/psi/dms/service/server/admin/SimpleApacheConfWriter.java
(original)
+++
branches/opensource/java/ch/psi/dms/service/server/admin/SimpleApacheHandler.java
Fri Jan 18 12:16:12 2008
@@ -8,12 +8,14 @@
import java.util.Set;
import ch.psi.dms.common.errorhandling.DmsException;
+import ch.psi.dms.common.errorhandling.ErrorType;
import ch.psi.dms.common.util.DmsPermission;
-public class SimpleApacheConfWriter implements ApacheConfWriter {
+public class SimpleApacheHandler implements ApacheHandler {
/**
- * @see
ch.psi.dms.service.server.admin.ApacheConfWriter#writeConfFile(java.lang.String,
java.lang.String, java.io.Writer)
+ * @see
ch.psi.dms.service.server.admin.ApacheHandler#writeConfFile(java.lang.String,
+ * java.lang.String, java.io.Writer)
*/
public void writeConfFile(String projectName, String repositoryName,
Writer writer) {
@@ -88,4 +90,17 @@
pw.close();
}
+ /**
+ * @see ch.psi.dms.service.server.admin.ApacheHandler#restartApache()
+ */
+ public void restartApache() throws DmsException {
+ int status = Admin.runShellCommand(new String[] {
+ "/usr/sbin/apache2ctl", "graceful" }, null);
+ if (status != 0) {
+ throw new DmsException(ErrorType.INTERNAL, null,
+ "Error when reloading Apache configuration",
+ "/usr/sbin/apache2ctl returned with error code " +
status);
+ }
+ }
+
}
Copied:
branches/opensource/sites/psi/java/ch/psi/dms/psi/service/server/admin/PSIApacheHandler.java
(from r677,
/branches/opensource/sites/psi/java/ch/psi/dms/psi/service/server/admin/PSIApacheConfWriter.java)
==============================================================================
---
/branches/opensource/sites/psi/java/ch/psi/dms/psi/service/server/admin/PSIApacheConfWriter.java
(original)
+++
branches/opensource/sites/psi/java/ch/psi/dms/psi/service/server/admin/PSIApacheHandler.java
Fri Jan 18 12:16:12 2008
@@ -8,9 +8,10 @@
import java.util.Set;
import ch.psi.dms.common.errorhandling.DmsException;
+import ch.psi.dms.common.errorhandling.ErrorType;
import ch.psi.dms.common.util.DmsPermission;
import ch.psi.dms.service.server.admin.Admin;
-import ch.psi.dms.service.server.admin.ApacheConfWriter;
+import ch.psi.dms.service.server.admin.ApacheHandler;
import ch.psi.dms.service.server.admin.TasknameParser;
/**
@@ -19,10 +20,10 @@
* Requires SSL connections and adds Kerberos user principals to *.svnaccess
* file.
*/
-public class PSIApacheConfWriter implements ApacheConfWriter {
+public class PSIApacheHandler implements ApacheHandler {
/**
- * @see
ch.psi.dms.service.server.admin.ApacheConfWriter#writeConfFile(java.lang.String,
+ * @see
ch.psi.dms.service.server.admin.ApacheHandler#writeConfFile(java.lang.String,
* java.lang.String, java.io.Writer)
*/
public void writeConfFile(String projectName, String repositoryName,
@@ -44,7 +45,7 @@
/**
* @throws DmsException
- * @see
ch.psi.dms.service.server.admin.ApacheConfWriter#writeSvnAccessFile(java.lang.String,
+ * @see
ch.psi.dms.service.server.admin.ApacheHandler#writeSvnAccessFile(java.lang.String,
* java.lang.String, java.util.Map, java.io.Writer)
*/
public void writeSvnAccessFile(String projectName, String repositoryName,
@@ -110,4 +111,14 @@
pw.close();
}
+ public void restartApache() throws DmsException {
+ int status = Admin.runShellCommand(new String[] {
+ "/usr/sbin/apachectl", "graceful" }, null);
+ if (status != 0) {
+ throw new DmsException(ErrorType.INTERNAL, null,
+ "Error when reloading Apache configuration",
+ "/usr/sbin/apachectl returned with error code " +
status);
+ }
+ }
+
}
- [idok-commit] idok commit r680 - in branches/opensource: java/ch/psi/dms/service/server/admin sites/psi/java/ch/psi/dms/psi/service/server/admin sites/psi/java/ch/psi/dms/service/server/admin, Apache, 01/18/2008
Archive powered by MHonArc 2.6.19.