From 5343a5007ff5923386304518f48f36bda353acf0 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 18 Mar 2013 00:35:04 -0400 Subject: [PATCH] Add executable detection, mysql and memcached to bin/web --- bin/web | 36 +++++++++++++++++++++++++++++------- install/brew | 1 - 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/bin/web b/bin/web index f42bdaf5..0d0d6cf6 100755 --- a/bin/web +++ b/bin/web @@ -2,23 +2,45 @@ # A start-script for my local webserver. Mac-only and requires Homebrew +BASE = File.expand_path(File.dirname(File.dirname(__FILE__))) PREFIX = `brew --prefix`.strip -CONF = "#{PREFIX}/dev/conf" +CONF = "#{BASE}/conf" PID = "#{PREFIX}/var/run" WWW = "#{PREFIX}/dev/www" -SERVICES = { - :php => { + + +## Services ### + +SERVICES = {} +if system("which php-fpm 2>&1 >/dev/null") + SERVICES[:php] = { :bin => `which php-fpm`.strip, :opts => "-p '/usr/local/var' -c '#{CONF}/php/php.ini' --fpm-config '#{CONF}/php/php-fpm.conf' --pid '#{PID}/php-fpm-pid'", :pid => "#{PID}/php-fpm.pid" - }, - :nginx => { + } +end +if system("which nginx 2>&1 >/dev/null") + SERVICES[:nginx] = { :bin => `which nginx`.strip, :opts => "-c '#{CONF}/nginx/nginx.conf'", :pid => "#{PID}/nginx.pid" } -} +end +if system("which memcached 2>&1 >/dev/null") + SERVICES[:memcached] = { + :bin => `which memcached`.strip, + :opts => "-d -P '#{PID}/memcached.pid' -u #{`whoami`.strip}", + :pid => "#{PID}/memcached.pid" + } +end +if system("which mysql.server 2>&1 >/dev/null") + SERVICES[:db] = { + :bin => "su #{`whoami`.strip} -c #{`which mysql.server`.strip} start", + :opts => "", + :pid => "#{PREFIX}/var/mysql/#{`hostname`}.pid" + } +end ## Functions ## @@ -62,7 +84,7 @@ def chdir end def help - puts "Usage: web (start|stop|restart)" + puts "Usage: web (start|stop|restart|chdir)" exit end diff --git a/install/brew b/install/brew index 93106abf..f3467a9e 100755 --- a/install/brew +++ b/install/brew @@ -30,7 +30,6 @@ if [ ! `command -v "brew"` ]; then brew install git brew install rename brew install tree - brew install daemon # vim brew install python ruby