SELinux
env PATH=$PATH:/usr/bin /home/xormon/xormon-ng/server-nest/node_modules/pm2/bin/pm2 startup systemd -u xormon --hp /home/xormon
# set the context for pm2 binary semanage fcontext -a -t bin_t "/home/xormon/xormon-ng/server-nest/node_modules/pm2/bin/pm2" # check context semanage fcontext --list | grep 'pm2' # apply changes restorecon -v /home/xormon/xormon-ng/server-nest/node_modules/pm2/bin/pm2 > /dev/null
mkdir /etc/systemd/system/pm2-xormon.service.d cat > /etc/systemd/system/pm2-xormon.service.d/override.conf << EOF [Service] ExecStartPre=+/bin/mkdir -p /run/xormon ExecStartPre=+/bin/chown xormon:xormon /run/xormon Environment=PM2_PID_FILE_PATH=/run/xormon/pm2.pid PIDFile=/run/xormon/pm2.pid EOF
systemctl daemon-reload systemctl enable pm2-xormon.service --now