I'm creating a startup script for a node.js environment using forever to launch the node server. I am trying to launch the forever command using su
to become another user for the process as I don't want to run it as root. The problem comes when the su
command starts a subshell to run the forever command in. The environment variables that we set on a per application basis don't make it down to the subshell that forever is running in. I've tried sourcing the file that contains the environment for our node script but apparently bash won't let you do that. So with all that background, here's the question:
How do I source in a shell script file when I launch forever into the subshell? Here's a snippet of the start function in my script:
exec su -s /bin/sh -c 'exec "$0" "$@"' $APPUSER -- . $CONFIGFILENAME; /usr/bin/forever
--pidFile $PIDFILE
-a
-l $FOREVERLOGFILE
-o $OUTLOGFILE
-e $ERRORLOGFILE
--minUptime $MIN_UPTIME
--spinSleepTime $SPIN_SLEEP_TIME
start $APPLICATION_PATH 2>&1 > /dev/null &
and the error I get when I run it is:
.: line 0: exec: .: not found
I've tried using the source
command as well as the .
command but apparently it doesn't like executing commands in a series when you fire it off with the su
command.