Skip to content

Instantly share code, notes, and snippets.

@etenzy
Created July 12, 2018 13:41
Show Gist options
  • Select an option

  • Save etenzy/a47768f6d5901ada67f7e45f25fe9733 to your computer and use it in GitHub Desktop.

Select an option

Save etenzy/a47768f6d5901ada67f7e45f25fe9733 to your computer and use it in GitHub Desktop.
function horizon() {
dir=${PWD}
case "$1" in
"start")
if [[ $(ps aux | grep "php $dir/artisan horizon" | grep -v grep | awk '{print $2}') ]]; then
echo "horizon is already running"
else
nohup php $dir/artisan horizon </dev/null >/dev/null 2>&1 &
echo "horizon started with pid: $(ps aux | grep "php $dir/artisan horizon" | grep -v grep | awk '{print $2}')"
fi
;;
"stop")
echo "kill $dir/artisan horizon"
kill $(ps aux | grep "php $dir/artisan horizon" | grep -v grep | awk '{print $2}')
;;
"status")
ps aux | grep "artisan horizon$" | grep -v grep
;;
*)
echo "Usage: horizon {start|stop|status}"
;;
esac
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment