Skip to content

Instantly share code, notes, and snippets.

@recurser
Forked from arzumy/control
Created May 25, 2011 23:59
Show Gist options
  • Save recurser/992264 to your computer and use it in GitHub Desktop.
Save recurser/992264 to your computer and use it in GitHub Desktop.
Simple script to start/stop services using launchctl in OSX, with easy to remember service's name.
#!/bin/bash
# usage: control (start|stop) service_shortname
# simple script by @arzumy
# I use this in my .bashrc
#
# alias start='~/scripts/control start '
# alias stop='~/scripts/control stop '
#
# Then I'll just type 'start mysql' to start mysql
# But make sure you've edited the pslist in ~/Library/LaunchAgents
# by changing KeepAlive's value to false.
case "$2" in
mysql) echo "$1 MySQL"
launchctl "$1" com.mysql.mysqld
;;
pg) echo "$1 postgresql"
launchctl "$1" org.postgresql.postgres
;;
nginx) echo "$1 nginx"
launchctl "$1" org.nginx
;;
mongo) echo "$1 mongodb"
launchctl "$1" org.mongodb.mongod
;;
redis) echo "$1 redis"
launchctl "$1" io.redis.redis-server
;;
memcached) echo "$1 memcached"
launchctl "$1" com.danga.memcached
;;
fs) echo "$1 MySQL, nginx, mongodb, redis, memcached"
launchctl "$1" com.mysql.mysqld
launchctl "$1" org.nginx
launchctl "$1" org.mongodb.mongod
launchctl "$1" io.redis.redis-server
launchctl "$1" com.danga.memcached
;;
*) echo "Service $2 not found"
;;
esac
@jimothyGator
Copy link

You might also want to check out Lunch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment