From 15d127ee94e981bf127fe6503cf4a10b9eeb8d31 Mon Sep 17 00:00:00 2001 From: Markus Weigelt Date: Fri, 1 Apr 2022 18:56:48 +0200 Subject: [PATCH] syslog logging of kitodo active mq client --- Dockerfile | 10 +++++++--- for_production.sh | 2 +- kitodo-activemq-client-log4j2.properties | 23 +++++++++++++++++++++++ start-sshd.sh | 7 +++++++ 4 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 kitodo-activemq-client-log4j2.properties diff --git a/Dockerfile b/Dockerfile index 2300caf..f7f2c62 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ FROM ocrd/core:latest MAINTAINER markus.weigelt@slub-dresden.de -ARG KITODO_MQ_CLIENT_VERSION=0.1 +ARG KITODO_MQ_CLIENT_VERSION=0.2 ENV HOME=/ @@ -26,9 +26,13 @@ RUN apt-get update && \ # configure writing to ocrd.log for profiling COPY ocrd_logging.conf /etc +# add activemq log4j properties +COPY kitodo-activemq-client-log4j2.properties /opt/kitodo-activemq-client/log4j2.properties +ENV ACTIVEMQ_CLIENT_LOG4J2 /opt/kitodo-activemq-client/log4j2.properties + # add ActiveMQ client library -ADD https://github.com/markusweigelt/kitodo-activemq-client/releases/download/${KITODO_MQ_CLIENT_VERSION}/kitodo-activemq-client-${KITODO_MQ_CLIENT_VERSION}.jar /opt -ENV ACTIVEMQ_CLIENT /opt/kitodo-activemq-client-${KITODO_MQ_CLIENT_VERSION}.jar +ADD https://github.com/markusweigelt/kitodo-activemq-client/releases/download/${KITODO_MQ_CLIENT_VERSION}/kitodo-activemq-client-${KITODO_MQ_CLIENT_VERSION}.jar /opt/kitodo-activemq-client +ENV ACTIVEMQ_CLIENT /opt/kitodo-activemq-client/kitodo-activemq-client-${KITODO_MQ_CLIENT_VERSION}.jar RUN chmod go+r $ACTIVEMQ_CLIENT # run OpenSSH server diff --git a/for_production.sh b/for_production.sh index 8eded6d..7d31045 100755 --- a/for_production.sh +++ b/for_production.sh @@ -74,7 +74,7 @@ CONTROLLERPORT=${CONTROLLER#*:} } # signal SUCCESS via ActiveMQ if test -n "$ACTIVEMQ" -a -n "$ACTIVEMQ_CLIENT"; then - java -jar "$ACTIVEMQ_CLIENT" "tcp://$ACTIVEMQ?closeAsync=false" "KitodoProduction.FinalizeStep.Queue" $TASK_ID $PROC_ID + java -Dlog4j2.configurationFile=$ACTIVEMQ_CLIENT_LOG4J2 -jar "$ACTIVEMQ_CLIENT" "tcp://$ACTIVEMQ?closeAsync=false" "KitodoProduction.FinalizeStep.Queue" $TASK_ID $PROC_ID fi )& diff --git a/kitodo-activemq-client-log4j2.properties b/kitodo-activemq-client-log4j2.properties new file mode 100644 index 0000000..6227743 --- /dev/null +++ b/kitodo-activemq-client-log4j2.properties @@ -0,0 +1,23 @@ +status = warn +# Name of the configuration +name = KitodoActiveMQClientLog4j2Config + +# Console appender configuration +appender.console.type = console +appender.console.name = ConsoleAppender +appender.console.layout.type = PatternLayout +appender.console.layout.pattern = %d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n + +# Syslog appender configuration +appender.syslog.type = Syslog +appender.syslog.name = SyslogAppender +appender.syslog.layout.type = PatternLayout +appender.syslog.layout.pattern = %d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n +appender.syslog.host = localhost +appender.syslog.port = 514 +appender.syslog.protocol = UDP +appender.syslog.facility = LOCAL0 + +rootLogger.level = info +rootLogger.appenderRef.stdout.ref = ConsoleAppender +rootLogger.appenderRef.SyslogAppender.ref = SyslogAppender \ No newline at end of file diff --git a/start-sshd.sh b/start-sshd.sh index cf8613e..5383767 100755 --- a/start-sshd.sh +++ b/start-sshd.sh @@ -4,6 +4,7 @@ cat /id_rsa >> /.ssh/id_rsa ssh-keyscan -H ${CONTROLLER%:*} >> /.ssh/known_hosts + # turn off the login banner touch /.hushlogin @@ -31,6 +32,12 @@ echo ocrd:*:19020:0:99999:7::: >> /etc/shadow #/usr/sbin/sshd -D -e service ssh start +# Replace imklog to prevent starting problems of rsyslog +/bin/sed -i '/imklog/s/^/#/' /etc/rsyslog.conf + +# rsyslog upd reception on port 514 +/bin/sed -i '/imudp/s/^#//' /etc/rsyslog.conf + service rsyslog start sleep 2