BASH   9

qcheck.sh

Guest on 13th May 2022 01:46:47 AM

  1. #!/bin/bash
  2.  
  3. PATH="/usr/local/php74/bin":$PATH
  4. export PATH
  5.  
  6. PHP_CLI_BIN=$1
  7. PROJECT_PATH=$2
  8.  
  9. run_queue() {
  10.     echo "run_queue"
  11.  
  12.     nohup $PHP_CLI_BIN $PROJECT_PATH/artisan queue:work --stop-when-empty &
  13.     echo $! >queue.pid
  14. }
  15.  
  16. if ! [ -f queue.pid ]; then
  17.     echo "no queue.pid file found"
  18.  
  19.     run_queue
  20. else
  21.     qpid=$(cat queue.pid)
  22.  
  23.     echo "qpid=$qpid"
  24.  
  25.     if kill -0 $qpid; then
  26.         echo "alive"
  27.     else
  28.         echo "dead"
  29.  
  30.         rm queue.pid
  31.         run_queue
  32.     fi
  33. fi

Raw Paste


Login or Register to edit or fork this paste. It's free.