Skip to content

Instantly share code, notes, and snippets.

@Ardakilic
Last active September 14, 2015 08:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ardakilic/590e637ffa8630e3ff56 to your computer and use it in GitHub Desktop.
Save Ardakilic/590e637ffa8630e3ff56 to your computer and use it in GitHub Desktop.
-sort of- daemon script to start / stop / restart nginx, redis, php-fpm and mysql that's installed from homebrew, run as user.
#! /bin/bash
if [ -n "$1" ]; then
if [ $1 = "start" ]; then
echo "Starting php-fpm ..."
launchctl load -w /usr/local/opt/php56/homebrew.mxcl.php56.plist
echo "Starting nginx ..."
sudo nginx
launchctl load -w /usr/local/opt/nginx/homebrew.mxcl.nginx.plist
echo "Starting mysql ..."
launchctl load -w /usr/local/opt/mysql/homebrew.mxcl.mysql.plist
echo "Starting Redis..."
launchctl load -w /usr/local/opt/redis/homebrew.mxcl.redis.plist
echo "Done!"
elif [ $1 = "stop" ]; then
sudo nginx -s stop
echo "Stopping mysql ..."
launchctl unload -w /usr/local/opt/mysql/homebrew.mxcl.mysql.plist
echo "Stopping php-fpm ..."
launchctl unload -w /usr/local/opt/php56/homebrew.mxcl.php56.plist
echo "Stopping nginx ..."
sudo nginx -s stop
echo "Stopping Redis..."
launchctl unload -w /usr/local/opt/redis/homebrew.mxcl.redis.plist
echo "Done!"
elif [ $1 = "restart" ]; then
echo "Stopping mysql ..."
launchctl unload -w /usr/local/opt/mysql/homebrew.mxcl.mysql.plist
echo "Stopping php-fpm ..."
launchctl unload -w /usr/local/opt/php56/homebrew.mxcl.php56.plist
echo "Stopping nginx ..."
sudo nginx -s stop
launchctl unload -w /usr/local/opt/nginx/homebrew.mxcl.nginx.plist
echo "Stopping Redis..."
launchctl unload -w /usr/local/opt/redis/homebrew.mxcl.redis.plist
echo "Starting php-fpm ..."
launchctl load -w /usr/local/opt/php56/homebrew.mxcl.php56.plist
echo "Starting nginx ..."
sudo nginx
launchctl load -w /usr/local/opt/nginx/homebrew.mxcl.nginx.plist
echo "Starting mysql ..."
launchctl load -w /usr/local/opt/mysql/homebrew.mxcl.mysql.plist
echo "Starting Redis..."
launchctl load -w /usr/local/opt/redis/homebrew.mxcl.redis.plist
echo "Done!"
fi
else
echo "Valid commands: "
echo "start | stop | restart"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment