mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Added EPMU's process control sake
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@61525 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
1dc0615f64
commit
9157113dca
78
sake
78
sake
@ -7,11 +7,16 @@ Executes a Sapphire command"
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Special case for "sake installsake"
|
# Set $sapphire and $base
|
||||||
if [ "$1" = "installsake" ]; then
|
if [ -d ./sapphire ]; then
|
||||||
echo "Installing sake to /usr/bin..."
|
sapphire=./sapphire
|
||||||
cp $0 /usr/bin
|
base=.
|
||||||
exit 0
|
elif [ -f ./cli-script.php ]; then
|
||||||
|
sapphire=.
|
||||||
|
base=..
|
||||||
|
else
|
||||||
|
echo "Can't find ./sapphire/cli-script.php or ./cli-script.php"
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Find the PHP binary
|
# Find the PHP binary
|
||||||
@ -21,20 +26,67 @@ for candidatephp in php5 php; do
|
|||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ "$php" = "" ]; then
|
if [ "$php" = "" ]; then
|
||||||
echo "Can't find any php binary"
|
echo "Can't find any php binary"
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -d ./sapphire ]; then
|
################################################################################################
|
||||||
$php ./sapphire/cli-script.php $1 $2
|
## Installation to /usr/bin
|
||||||
exit $?
|
|
||||||
|
if [ "$1" = "installsake" ]; then
|
||||||
|
echo "Installing sake to /usr/bin..."
|
||||||
|
cp $0 /usr/bin
|
||||||
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f ./cli-script.php ]; then
|
################################################################################################
|
||||||
$php ./cli-script.php $1 $2
|
## Process control
|
||||||
exit $?
|
|
||||||
|
if [ "$1" = "-start" ]; then
|
||||||
|
if [ "`which daemon`" = "" ]; then
|
||||||
|
echo "You need to install the 'daemon' tool. In debian, go 'sudo apt-get install daemon'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f $base/$2.pid ]; then
|
||||||
|
echo "Starting service $2 $3"
|
||||||
|
touch $base/$2.pid
|
||||||
|
pidfile=`realpath $base/$2.pid`
|
||||||
|
|
||||||
|
outlog=$base/$2.log
|
||||||
|
errlog=$base/$2.err
|
||||||
|
|
||||||
|
echo "Logging to $outlog"
|
||||||
|
|
||||||
|
sake=`realpath $0`
|
||||||
|
base=`realpath $base`
|
||||||
|
|
||||||
|
# TODO: Give a globally unique processname by including the projectname as well
|
||||||
|
processname=$2
|
||||||
|
|
||||||
|
daemon -n $processname -r -D $base --pidfile=$pidfile --stdout=$outlog --stderr=$errlog $sake $2 $3
|
||||||
|
else
|
||||||
|
echo "Service $2 seems to already be running"
|
||||||
|
fi
|
||||||
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Can't find ./sapphire/cli-script.php or ./cli-script.php"
|
if [ "$1" = "-stop" ]; then
|
||||||
|
pidfile=$base/$2.pid
|
||||||
|
if [ -f $pidfile ]; then
|
||||||
|
echo "Stopping service $2"
|
||||||
|
|
||||||
|
# TODO: This is a bad way of killing the process
|
||||||
|
kill -KILL `cat $pidfile`
|
||||||
|
unlink $pidfile
|
||||||
|
else
|
||||||
|
echo "Service $2 doesn't seem to be running."
|
||||||
|
fi
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
################################################################################################
|
||||||
|
## Basic execution
|
||||||
|
|
||||||
|
$php $sapphire/cli-script.php $1 $2
|
||||||
|
Loading…
Reference in New Issue
Block a user