Reputation: 3597
I'm trying to setup AEM (Adobe Experience Manager) Author as a Service on Ubuntu 18.04 on an AWS EC2 instance.
Script file "aem" at /usr/bin/aem
(file permissions to "root")
#!/bin/bash
#
# description: This service manages the Adobe Experience Manager java process.
# processname: aem6
. /lib/lsb/init-functions
SCRIPT_NAME=`basename $0`
AEM_ROOT=/opt/aem/author
AEM_USER=root
########
BIN=${AEM_ROOT}/crx-quickstart/bin
START=${BIN}/start
STOP=${BIN}/stop
STATUS=${BIN}/status
case "$1" in
start)
if [ -f $START ]; then
echo "Starting AEM Service.."
/bin/su -l $AEM_USER -c $START
RETVAL=$?
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/${SCRIPT_NAME}
fi
;;
stop)
if [ -f $STOP ]; then
echo "Stopping AEM Service.."
/bin/su -l $AEM_USER -c $STOP
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/${SCRIPT_NAME}
fi
;;
status)
if [ -f $STATUS ]; then
echo -s "Checking status of $SCRIPT_NAME: "
/bin/su -l $AEM_USER -c $STATUS
RETVAL=$?
[ $RETVAL -eq 0 ] && echo "$SCRIPT_NAME is running"
fi
;;
restart)
/bin/su -l ${AEM_USER} -c ${STOP}
/bin/su -l ${AEM_USER} -c ${START}
;;
reload)
;;
*)
echo "Usage: $0 {start|stop|status|reload}"
RETVAL=1
;;
esac
exit $RETVAL
Service file at /etc/systemd/system/aem.service
(file permissions to "root")
[Unit]
Description=Adobe Experience Manager
[Service]
Type=simple
ExecStart=/usr/bin/aem start
ExecStop=/usr/bin/aem stop
ExecReload=/usr/bin/aem restart
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
when checking the service status:
ubuntu@ip-109:~$ sudo systemctl status aem
aem.service - Adobe Experience Manager
Loaded: loaded (/etc/systemd/system/aem.service; enabled; vendor preset: enabled)
Active: active (exited) since Wed 2019-10-23 20:25:21 UTC; 3min 24s ago
Process: 20106 ExecStart=/usr/bin/aem start (code=exited, status=0/SUCCESS)
Main PID: 20106 (code=exited, status=0/SUCCESS)
Oct 23 20:25:21 ip-172-31-14-109 systemd[1]: Started Adobe Experience Manager.
Oct 23 20:25:21 ip-172-31-14-109 aem[20106]: Starting AEM Service..
Oct 23 20:25:21 ip-172-31-14-109 su[20122]: Successful su for root by root
Oct 23 20:25:21 ip-172-31-14-109 su[20122]: + ??? root:root
Oct 23 20:25:21 ip-172-31-14-109 su[20122]: pam_unix(su:session): session opened for user root by (uid=0)
Oct 23 20:25:21 ip-172-31-14-109 aem[20106]: mesg: ttyname failed: Inappropriate ioctl for device
Oct 23 20:25:21 ip-172-31-14-109 su[20122]: pam_unix(su:session): session closed for user root
But cannot see "java" process (using ps -ef | grep java
) or port "4502" being used (using sudo lsof -i -P -n | grep LISTEN
).
What am i missing?
Upvotes: 0
Views: 625
Reputation: 3597
Was able to resolve the issue. The problem was with "java" not being available to all users. Installed Oracle Java using default (ubuntu) user, while the aem
script was running as root
.
Steps to install custom Java.. not the Ubuntu default:
tar.gz
file "https://download.oracle.com/otn/java/jdk/8u231-b11/5b13a193868b4bf28bcb45c792fce896/jdk-8u 231-linux-x64.tar.gz"mkdir /opt/java
sudo tar -zxf jdk-8u231-linux-x64.tar.gz -C /opt/java/
sudo update-alternatives --install /usr/bin/java java /opt/java/jdk1.8.0_231/bin/java 1
sudo nano ~/.bashrc
export JAVA_HOME=/opt/java/jdk1.8.0_231
export PATH=${PATH}:${JAVA_HOME}/bin
After this.. start the "aem" service again. It should be working!
Upvotes: 1