Hi,
we are trying to install enterprise search as a service.
We have configured the enterprise-search.yml configuration file as needed and are able to start the component as a process.
However, when we try to start the service with the same user used to start the process, we get the following error:
--
mkdir: cannot create directory ‘log’: Permission denied
--
We tried starting the service in two different modes: systemctl and init.d, with both we get the same error, despite giving the logs folder the necessary permissions.
Below are the two files used to configure the services:
systemctl
[Unit]
Description=Enterprise Search
Documentation=http://www.elastic.co
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
User=elastic
Group=elastic
ExecStart=/bin/bash /home/elastic/enterprisesearch/enterprise-search-8.12.1/bin/enterprise-search
StandardOutput=journal
StandardError=inherit
LimitNOFILE=65536
LimitMEMLOCK=infinity
TimeoutStopSec=0
KillSignal=SIGTERM
SendSIGKILL=no
SuccessExitStatus=143
[Install]
WantedBy=multi-user.target
init.d
#!/bin/bash
#/etc/init.d/enterprise
DESC="Enterprise Search"
DAEMON=/home/elastic/enterprisesearch/enterprise-search-8.12.1/bin/enterprise-search
DAEMON_ARGS=""
PIDFILE=/var/run/enterprise.pid
LOGFILE=/var/log/enterprise-search.log
USER=elastic
GROUP=elastic
start() {
echo "Starting $DESC"
if [ -f "$PIDFILE" ]; then
echo "$DESC is already running."
exit 1
fi
su -s /bin/bash -c "$DAEMON $DAEMON_ARGS > $LOGFILE 2>&1" $USER &
echo $! > $PIDFILE
}
stop() {
echo "Stopping $DESC"
if [ ! -f "$PIDFILE" ]; then
echo "$DESC is not running."
exit 1
fi
kill $(cat $PIDFILE)
rm $PIDFILE
}
status() {
if [ -f "$PIDFILE" ]; then
echo "$DESC is running, pid $(cat $PIDFILE)"
else
echo "$DESC is not running"
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
status
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
;;
esac
exit 0
Can you help me figure out where the problem is?
Consider that we tested on AMI LINUX2/RHEL 8/9 and with all of them we get the same problem. SELinux is disabled.
Best regards,
Federica