I have downloaded the Cloud9 IDE to my Mac according to the instructions on https://github.com/ajaxorg/cloud9 and everything works fine. But, I cannot seem to get it to run in the background, launching via a bash script:
Bash script called "ide" and has executable privileges:
#!/usr/bin/env sh
CLOUD_USER=`whoami`
CLOUD_DIR="/Users/$CLOUD_USER/Sites/cloud9"
CLOUD_PORT=3333
CLOUD_WORKSPACE="/Users/$CLOUD_USER/Sites"
CLOUD_ACTION="open"
CLOUD_BEFORE=""
CLOUD_AFTER=""
case "$1" in
-b)
CLOUD_BEFORE="nohup "
CLOUD_AFTER="> /dev/null 2>&1 &"
;;
.)
CLOUD_WORKSPACE=`pwd`
CLOUD_AFTER="-a $CLOUD_ACTION"
;;
*)
if [ $1 ]; then
CLOUD_WORKSPACE=$1
fi
CLOUD_AFTER="-a $CLOUD_ACTION"
;;
esac
$CLOUD_BEFORE`/usr/local/node/bin/node $CLOUD_DIR/bin/cloud9.js -p $CLOUD_PORT -w $CLOUD_WORKSPACE` $CLOUD_AFTER
The idea is that you can launch this several ways:
$ ide
Will start Cloud9 and launch using the ~/Sites folder as the workspace. Or you can specify the workspace by running:
$ ide /path/to/workspace
or run the server in the background:
$ ide -b
... which doesn't exit the script.
I've tried downloading "forever" (https://github.com/indexzero/forever). But, when I run it in forever it takes over stdio and won't return to the command prompt.
If I run the following in the command line it runs in the background and exists correctly:
$ nohup /usr/local/node/bin/node /Users/{user}/Sites/cloud9/bin/cloud9.js -p 3333 -w /Users/{user}/Sites > /dev/null 2>&1 &
But, not when I run the script itself.
Any ideas about how I can force this to run in the background?
change line
$CLOUD_BEFORE`/usr/local/node/bin/node $CLOUD_DIR/bin/cloud9.js -p $CLOUD_PORT -w $CLOUD_WORKSPACE` $CLOUD_AFTER
to
$CLOUD_BEFORE"/usr/local/node/bin/node $CLOUD_DIR/bin/cloud9.js -p $CLOUD_PORT -w $CLOUD_WORKSPACE "$CLOUD_AFTER
i'm test on the following example:
[kaero@54221-2 ~]$ SF="sudo "
[kaero@54221-2 ~]$ FS=" aux"
[kaero@54221-2 ~]$ $SF`ps`$FS
Password:
sudo: PID: command not found
[kaero@54221-2 ~]$ $SF"ps"$FS
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With