Monday, January 16, 2012

PostgreSQL autostart on Mac OS X

I installed PostgreSQL 9.0 from „One Click Installer” and didn't want it to launch as system starts.

As PostgreSQL has been installed launchctl takes responsibility to take care of always running PostgreSQL daemon. /Library/LaunchDaemons/com.edb.launchd.postgresql-9.0.plist file sets up the daemon's behavior.

There are two options that can prevent the daemon after start up.
<key>Disabled</key>
<false/>

<key>RunAtLoad</key>
<true/>

„Disabled”=True prevents the job from loading at all and there will be not possible start the job even manually.
„RunAtLoad”=Fasle tells the launchctl not to run the job after loading.

Here we are, set „RunAtLoad” to False and the daemon won't be run automatically.

By the way, there are useful commands below to run and stop the daemon though:

sudo launchctl list | grep postgresql
display current daemon's pid or exit code.

sudo launchctl start com.edb.launchd.postgresql-9.0
start the daemon

sudo launchctl stop com.edb.launchd.postgresql-9.0
and stop it

Wednesday, January 4, 2012

Tab-completion for django-admin.py and manage.py

Download django_bash_completion file and save in some convenient place in your system. In .bash_profile (or .bashrc if it doesn't envoke .bash_profile) add
. ~/path/to/django_bash_completion
Settings will take effect the next time you log in.