On Wed, Aug 21, 2019 at 7:30 PM Debraj Manna <subharaj.manna@xxxxxxxxx> wrote:
I am having a unit file like below running on Ubuntu 16.04 with systemd version 229.[Unit]
Description=Hadoop-Yarn-Resourcemanager Service
[Service]
Type=simple
Environment=JAVA_HOME=/usr/lib/jvm/jdk1.8
Environment=YARN_USER=yarn
Environment=YARN_IDENT_STRING=yarn
Environment=YARN_PID_DIR=/var/run/hadoop-yarn
Environment=YARN_LOG_DIR=/var/log/hadoop-yarn
Environment=YARN_CONF_DIR=/etc/hadoop/conf
Environment=HADOOP_LIBEXEC_DIR=/usr/lib/hadoop/libexec
IgnoreSIGPIPE=false
ExecStart=/home/ubuntu/build-target/cdh/yarn-rm/hadoop-yarn-resourcemanager-sysd-start.sh
ExecStopPost=-/bin/bash /home/ubuntu/build-target/cdh/yarn-rm/hadoop-yarn-resourcemanager-sysd-poststop.sh
ExecStopPost=-/bin/sleep 1
RestartSec=2s
Restart=always
[Install]
WantedBy=multi-user.targethadoop-yarn-resourcemanager-sysd-start.sh looks like below#!/bin/bash
echo "Running pre-steps for hadoop-yarn-resourcemanager"
sudo mkdir -p $YARN_LOG_DIR
sudo chown -R yarn:hadoop $YARN_LOG_DIR
sudo mkdir -p $YARN_PID_DIR
sudo chown yarn:yarn $YARN_PID_DIR
echo "Starting hadoop-yarn-resourcemanager"
sudo -u yarn /usr/lib/hadoop-yarn/sbin/yarn-daemon.sh start resourcemanager
sleep 3
echo "Starting health check for hadoop-yarn-resourcemanager"
/home/ubuntu/build-target/cdh/yarn-rm/hadoop-yarn-resourcemanager-sysd-health.sh
res=$?
Usually `sudo` resets all environment variables except whitelisted ones. That's not a systemd thing – pid1 *cannot* affect how environment variables are inherited.
Don't use sudo in systemd startup scripts. Create the pid_dir using RuntimeDirectory= (or tmpfiles.d), then just start yarn-daemon from ExecStart directly with User=yarn.
And probably more importantly, don't start multiple services from a single .service unit – it will never work well... (Chances are, if you do this, you won't even *need* a PIDFile because systemd will be able to track the process directly.)
Mantas Mikulėnas
_______________________________________________ systemd-devel mailing list systemd-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/systemd-devel