Skip to content

Commit

Permalink
Merge branch 'fb-DSS-2633-Performance_StressTest_client_does_not_prin…
Browse files Browse the repository at this point in the history
…t_the_result' into 'main'

DSS-2633:  performance stresstest client does not print the result

See merge request signserver/signserver!304
  • Loading branch information
mlundblad committed Dec 4, 2023
2 parents a04db3f + 3829457 commit d9c34d5
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*************************************************************************
* *
* SignServer: The OpenSource Automated Signing Server *
* *
* This software is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
* License as published by the Free Software Foundation; either *
* version 2.1 of the License, or any later version. *
* *
* See terms of license at gnu.org. *
* *
*************************************************************************/
package org.signserver.cli;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.impl.Log4jContextFactory;
import org.apache.logging.log4j.core.util.DefaultShutdownCallbackRegistry;
import org.apache.logging.log4j.spi.LoggerContextFactory;

/**
* Class containing helper method for log4j.
*
* @author Nima Saboonchi
*/
public class Log4jHelper {

/**
* Helper method for disabling the shutdown hook in log4j.
*/
public static void disableShutdownHook(){
final LoggerContextFactory loggerContextFactory = LogManager.getFactory();
if (loggerContextFactory instanceof Log4jContextFactory) {
Log4jContextFactory contextFactory = (Log4jContextFactory) loggerContextFactory;
((DefaultShutdownCallbackRegistry) contextFactory.getShutdownCallbackRegistry()).stop();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.log4j.Logger;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.tsp.TSPAlgorithms;
import org.signserver.cli.Log4jHelper;
import org.signserver.common.InvalidWorkerIdException;
import org.signserver.test.performance.FailureCallback;
import org.signserver.test.performance.WorkerThread;
Expand Down Expand Up @@ -139,6 +140,9 @@ private static void printUsage() {
* @param args the command line arguments
*/
public static void main(String[] args) throws RemoteException, InvalidWorkerIdException {
// Disable shutdown hook for log4j
Log4jHelper.disableShutdownHook();

try {
if (LOG.isDebugEnabled()) {
LOG.debug("(Debug logging is enabled)");
Expand Down

0 comments on commit d9c34d5

Please sign in to comment.