Friday, September 26, 2014

Autostart App on Macintosh, just load PLIST files at LaunchAgents such as (Mysql, Mongod and Redis)

Mysql 


brew info mysql
mkdir -p ~/Library/LaunchAgents
cp `brew --prefix mysql`/*mysql*.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/*mysql*.plist

or 

cp /usr/local/opt/mysql/homebrew.mxcl.mysql.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist



Mongod 

Create a file call org.mongo.mongod.plist in /Library/LaunchDaemons/

If you use vim you can do like this:
sudo vim /Library/LaunchDaemons/org.mongo.mongod.plist  

Copy and paste this:
 
 
"1.0">  
 
    Label
    org.mongo.mongod
    RunAtLoad
   
    ProgramArguments
   
        /usr/local/bin/mongod
        --dbpath
        /var/lib/mongodb/
        --logpath
        /var/log/mongodb.log
   
 


Also, you will need to create a file for the log and a directory for the database.
sudo touch /var/log/mongodb.log  
sudo mkdir /var/lib/mongodb  

And run this in your terminal:
sudo chown root:wheel /Library/LaunchDaemons/org.mongo.mongod.plist  
sudo launchctl load /Library/LaunchDaemons/org.mongo.mongod.plist  
sudo launchctl start org.mongo.mongod  


Redis

To have launchd start redis at login:
    ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents
Then to load redis now:
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
Or, if you don't want/need launchctl, you can just run:
    redis-server /usr/local/etc/redis.conf

No comments:

Post a Comment