#!/bin/sh
# Check if a service is running.
function running() {
if ps ax | grep -v grep | grep "$1" &> /dev/null; then
return 0
else
return 1
fi;
}
if running "nginx" && ! running "mysqld"; then
brew services start mysql
elif ! running "nginx" && running "mysqld"; then
valet start
elif ! running "nginx" && ! running "mysqld"; then
valet start
brew services start mysql
else running "nginx" && running "mysqld";
valet stop
brew services stop mysql
fi