<div dir="ltr">Thanks Silvio for replying. I will check your suggestions.<div><br></div><div>But it appears this is some issue with systemd version 229 as mentioned in <a href="https://unix.stackexchange.com/a/417632">https://unix.stackexchange.com/a/417632</a></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jul 25, 2019 at 4:09 PM Silvio Knizek <<a href="mailto:killermoehre@gmx.net">killermoehre@gmx.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Am Donnerstag, den 25.07.2019, 15:55 +0530 schrieb Debraj Manna:<br>
> I have unit file which looks like below. I am seeing some of the echo<br>
> are<br>
> showing up in syslog but not in journalctl. Can someone let me know<br>
> what is<br>
> going on?<br>
> systemd version 229 running on Ubuntu 16.<br>
><br>
> [Unit]<br>
> Description=Kafka Service<br>
><br>
> [Service]<br>
> Type=simple<br>
> Environment=KAFKA_HOME=/home/ubuntu/deploy/kafka<br>
> Environment=LIB_DIR=/var/lib/kafka<br>
> Environment=LOG_DIR=/var/log/kafka<br>
> Environment=TEMP_DIR=/home/ubuntu/tmp<br>
> Environment=TOOLS_JAR=/home/ubuntu/build-target/common-utils/tools-<br>
> 0.001-SNAPSHOT.jar<br>
> Environment=MIN_DATA_PARTITION_FREE_SPACE_PCT=10<br>
> Environment=MIN_DATA_PARTITION_FREE_SPACE_GB=10<br>
> Environment=DATA_PARTITION_NAME=/var<br>
><br>
> ExecStartPre=-/bin/mkdir -p /var/log/kafka<br>
> ExecStartPre=-/bin/chown -R ubuntu:ubuntu /var/log/kafka<br>
> ExecStartPre=-/bin/mkdir -p /var/lib/kafka/kafka-logs<br>
> ExecStartPre=-/bin/chown -R ubuntu:ubuntu /var/lib/kafka/kafka-logs<br>
> ExecStartPre=-/bin/rm -f /var/log/kafka/kafka-logs/.lock<br>
> ExecStartPre=-/bin/mkdir -p /home/ubuntu/tmp<br>
> ExecStartPre=-/bin/chown -R ubuntu:ubuntu /home/ubuntu/tmp<br>
> ExecStartPre=-/bin/chmod -R 775 /home/ubuntu/tmp<br>
> ExecStartPre=-/bin/su ubuntu -c<br>
> "/home/ubuntu/build-target/kafka/kafka-systemd-prestart.sh"<br>
> ExecStart=/bin/su ubuntu -c<br>
> "/home/ubuntu/build-target/kafka/kafka-systemd-health.sh"<br>
> ExecStopPost=-/bin/bash<br>
> /home/ubuntu/build-target/kafka/kafka-systemd-poststop.sh<br>
> RestartSec=2s<br>
> Restart=always<br>
> LimitNOFILE=65535<br>
> KillSignal=SIGTERM<br>
> SendSIGKILL=no<br>
> SuccessExitStatus=1 143<br>
><br>
> [Install]<br>
> WantedBy=multi-user.target<br>
><br>
> kafka-systemd-prestart.sh looks like below<br>
><br>
> echo "[`date +"%h %d %Y %H:%M:%S-%3N"`] Starting kafka..."<br>
> timeout --signal=sigkill 600s java -cp "$TOOLS_JAR"<br>
> com.vnera.tools.kafka.KafkaIndexValidator "$LIB_DIR/kafka-logs"<br>
> "$KAFKA_HOME/config/server.properties" true<br>
> broker_id=`sudo grep -F "<a href="http://broker.id" rel="noreferrer" target="_blank">broker.id</a>"<br>
> $KAFKA_HOME/config/server.properties | awk -F '=' '{print $2}'`<br>
> zookeeper_list=`sudo grep -F "zookeeper.connect="<br>
> $KAFKA_HOME/config/server.properties | awk -F '=' '{print $2}'`<br>
> echo "attempting removal of broker id $broker_id"<br>
><br>
> used_pct=`df ${DATA_PARTITION_NAME} --output=pcent | grep -v Use |<br>
> grep -o '[^ ]*[^ %]'`<br>
> free_pct=$(expr 100 - $used_pct)<br>
> free_gb=`df -h ${DATA_PARTITION_NAME} --output=avail --block-size G |<br>
> grep -v Avail | grep -o '[^ ]*[^ G]'`<br>
> echo "[`date +"%h %d %Y %H:%M:%S-%3N"`] partition<br>
> ${DATA_PARTITION_NAME} free% $free_pct required%<br>
> ${MIN_DATA_PARTITION_FREE_SPACE_PCT} freegb ${free_gb} required<br>
> ${MIN_DATA_PARTITION_FREE_SPACE_GB}"<br>
><br>
> # Some other code<br>
><br>
> kafka-systemd-poststop.sh looks like below<br>
><br>
> -------------------<br>
><br>
> echo "[`date +"%h %d %Y %H:%M:%S-%3N"`] Exiting kafka..."<br>
> cmd="ps -ef | grep -v grep | grep kafkaServer"<br>
><br>
> # Some other code<br>
><br>
> echo "completed exiting kafka"<br>
><br>
> Doing sudo journalctl -u kafka.service looks like below<br>
><br>
> Jul 25 07:41:39 platform2 systemd[1]: Started Kafka Service.<br>
> Jul 25 07:41:39 platform2 su[39160]: Successful su for ubuntu by root<br>
> Jul 25 07:41:39 platform2 su[39160]: + ??? root:ubuntu<br>
> Jul 25 07:41:39 platform2 su[39160]: pam_unix(su:session): session<br>
> opened for user ubuntu by (uid=0)<br>
> Jul 25 07:41:40 platform2 bash[39192]: [Jul 25 2019 07:41:40-572]<br>
> Exiting kafka...<br>
><br>
> I am not seeing some of the echo from kafka-systemd-prestart.sh in<br>
> journatl but I am seeing those logs in syslog<br>
><br>
> Jul 25 10:17:03 platform2 su[38464]: WatchedEvent state:SyncConnected<br>
> type:None path:null<br>
> Jul 25 10:17:03 platform2 su[38464]: Node does not exist:<br>
> /brokers/ids/2<br>
> Jul 25 10:17:03 platform2 su[38464]: [Jul 25 2019 10:17:03-343]<br>
> partition /var free% 9 required% 10 freegb 134 required 10<br>
> Jul 25 10:17:03 platform2 su[38464]: [Jul 25 2019 10:17:03-344]<br>
> Sufficient disk space is not available, sleeping for 60 seconds<br>
> before<br>
> exiting...<br>
<br>
Hi,<br>
<br>
first of all, take a look at man:tmpfiles.d to replace the whole<br>
mkdir/chmod ExecStartPre= stuff.<br>
Second, don't use »su« in .service. It breaks stuff by creating a new<br>
cgroup hierarchy because it's run through pam. Use User= instead.<br>
With both this changes your shell scripts shouldn't be necessary at all<br>
and than everything should land in the journal.<br>
Please don't re-invent the stuff systemd is already providing.<br>
<br>
BR<br>
Silvio<br>
<br>
_______________________________________________<br>
systemd-devel mailing list<br>
<a href="mailto:systemd-devel@lists.freedesktop.org" target="_blank">systemd-devel@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/systemd-devel" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/systemd-devel</a></blockquote></div>