Mac Ports Load / Unload a Process (like postgres)
This’ll be quick. If you use MacPorts on your OS X machine to install and manage *nix’y apps like MySQL, Postgres, Redis, Memcached etc you’ll want an easy way to start and stop them. On Ubuntu (or other *nix envs) you might have used /etc/init.d/somescript to start and stop an app. In OS X with MacPorts you’ll have to try something else.
MacPorts has the load and unload commands, which work with the Mac’s launchctl app to start and stop things. So once I have installed postgresql90-server I can start it via “sudo port load postgresql90-server”. Then you can try “ps aux | grep postgres” to find the process is running. This works for many of the other apps you will install. Look in the /Library/LaunchDaemons folder to see what plist files you have installed. For any one port load/unload will work if you give it the last part of the plist file name prior to the plist extension itself. So for org.macports.memcached.plist you can do a “sudo port load memcached”.
Thanks for this little post. I had installed Memcached using MacPorts and it defaults to using 64M, but I needed 128M. I was able to edit:
sudo vi /Library/LaunchDaemons/org.macports.memcached.plist
and change 64 to 128 (the ‘-m’ option). A quick ‘unload’/ ‘load’ and I was in business.
Great, glad I could help! I keep a lot of these blog posts for my own good. I can’t tell you how often a year goes by and I forget something then spend half and hour finding the information I need. So I always try and keep a record in one of my blogs