-
-
Save schatteleyn/2003752 to your computer and use it in GitHub Desktop.
Convenient command line methods
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/usr/bin/ruby /Users/schatteleyn/manager.rb $1 $2 $3 $4 $5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SYSTEM =================================== | |
if ARGV[0] == "flushdns" | |
puts "Flushing DNS Cache" | |
@command = "sudo dscacheutil -flushcache" | |
# REDIS ==================================== | |
elsif ARGV[0] == "redis" | |
if ARGV[1] == "start" | |
puts "Starting Redis" | |
@command = "nohup redis-server > /dev/null &" | |
elsif ARGV[1] == "stop" | |
puts "Stopping Redis" | |
@command = "kill `pidof redis-server`" | |
end | |
# ELASTIC SEARCH =========================== | |
if ARGV[1] == "start" | |
puts ">> Starting Elastic Search" | |
@command = "elasticsearch -D es.config=/usr/local/Cellar/elasticsearch/0.19.0/config/elasticsearch.yml -D es.pidfile=/usr/local/var/run/elasticsearch.pid" | |
elsif ARGV[1] == 'stop' | |
puts '>> Stopping Elastic Search' | |
@command = "kill `cat /usr/local/var/run/elasticsearch.pid`" | |
end | |
# SIMPLE HTTP ============================== | |
elsif ARGV[0] == "serve" | |
puts "Starting Python HTTP Server" | |
@command = "python -m SimpleHTTPServer" | |
# MYSQL ==================================== | |
elsif ARGV[0] == "mysql" | |
if ARGV[1] == "start" | |
@command = "mysql.server start" | |
elsif ARGV[1] == "stop" | |
@command = "mysql.server stop" | |
end | |
# APACHE =================================== | |
elsif ARGV[0] == "ap" | |
if ARGV[1] == "start" | |
puts "Starting Apache" | |
@command = "sudo apachectl start" | |
elsif ARGV[1] == "stop" | |
puts "Shutting Down Apache" | |
@command = "sudo apachectl stop" | |
elsif ARGV[1] == "restart" | |
puts "Restarting Apache" | |
@command = "sudo apachectl restart" | |
end | |
end | |
if @command | |
if system @command | |
puts "Done!" | |
else | |
puts "Error!" | |
end | |
else | |
puts "Unknown Command!" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment