I'm trying to run Mule on Ubuntu 14.04 as a service. I created the following init script (
#!/bin/bash JAVA_HOME=/usr/lib/jvm/java-8-oracle PATH=$PATH:$JAVA_HOME/bin # Set Mule related environment MULE_HOME=/opt/mule PATH=$PATH:$MULE_HOME/bin RUN_AS_USER=mule # Export environment variables export JAVA_HOME MULE_HOME RUN_AS_USER PATH # Invoke Mule $MULE_HOME/bin/mule $1
Here I define some environment variables, most notably
RUN_AS_USER since I want Mule to run as user
When I call
sudo service mule start I see nothing happening but when calling
sudo /etc/init.d/mule start, Mule starts running fine.
Looking at the startup script for Mule, on line 419 the script is relaunched if it needs to be run as another user.
RELAUNCH_CMD="$REALPATH $@" su -m $RUN_AS_USER -c "$RELAUNCH_CMD"
Why is it that when calling the init script directly, Mule starts running fine but when using the service utility, nothing happens? The man page for service says that it removes most environment variables. So I'm guessing that calling
su depends on the environment somehow.