Last active
August 29, 2015 14:22
-
-
Save tairov/af88c3bf347ed40d25d3 to your computer and use it in GitHub Desktop.
shell, run daemons, run all, start all daemons
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# need set actual path | |
ROOT_PATH=shell/daemons | |
# Don't edit | |
$ROOT_PATH/run.sh "service.php" 1 production 2>&1 >> /var/log/php5/task.log | |
$ROOT_PATH/run.sh "service.php" 10 production 2>&1 >> /var/log/php5/task.log | |
$ROOT_PATH/run.sh "service.php" 1 production 2>&1 >> /var/log/php5/prod_rmq_task.log | |
run.sh | |
#!/bin/sh | |
# need set actual path and application_env | |
ROOT_PATH=///shell/daemons | |
PID_PATH=/var/run | |
PHP=/usr/bin/php | |
APPLICATION_ENV=dev | |
# Don't edit | |
if [ "x$1" = "x" ]; then | |
echo "unknown deamon script name" | |
exit 0 | |
fi | |
EXEC_SCRIPT_NAME=$1 | |
EXEC_SCRIPT=$ROOT_PATH/$EXEC_SCRIPT_NAME | |
DAEMON="$PHP $EXEC_SCRIPT" | |
PIDFILE=$PID_PATH/$EXEC_SCRIPT_NAME-`hostname`-$2.run | |
[ -f $EXEC_SCRIPT ] || exit 0 | |
if [ -f $PIDFILE ] ; then | |
PID=`cat $PIDFILE` | |
if [ "x$PID" != "x" ] && kill -0 $PID 2>/dev/null ; then | |
echo "$EXEC_SCRIPT_NAME (pid $PID) running" | |
exit 0 | |
fi | |
fi | |
export APPLICATION_ENV | |
cd $ROOT_PATH | |
if [ "x$4" = "x" ] ; then | |
$DAEMON 2>&1 >> /site/logs/daemon-$EXEC_SCRIPT_NAME.log & | |
else | |
echo Output to: $4 | |
$DAEMON >> $4 & | |
fi | |
echo $! > $PIDFILE | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment