I have a dev and QA web server running on the same EC2. I've created a shell script (which is called via Cron) to check to see if a process is running and if not, restart it.
Shell script:
#!/bin/bash
process="php"
makerun="/usr/bin/php /var/www/html/api/artisan queue:work --queue=high,default --memory=512"
if ps ax | grep -v grep | grep $process > /dev/null
then
exit
else
$makerun &>/dev/null &
fi
exit
This all works well and great but it's now time to start the worker for our QA server (the above is dev) and obviously it's not going to do anything since the process name will be the same in both cases.
That said, does anybody know of a way to determine what invoked the process? If I knew that one was launched from the dev path then I could rewrite the bash script to be much smarter and in turn monitor the process for both dev and QA.
Any insight would be appreciated!