I setup Postgresql as database for Django and it works as a charm. However, today I got a error message when I tried to migrate my django.
sudo lsof -i :5432 returned nothing. It looks that my local database is down, so I tried
brew services start postgresql@10, and got message:
I tried to restart postgresql, but it did not help.
Maybe there is a stuck lockfile somewhere? Here is a clue as well as a few workarounds. I examine the content of
cat /usr/local/var/postgresql@10/postmaster.pid and kill the lock file by
kill -9 <PID>. Upon restarting the services, now it works again.
kill -9 might not be a good way to kill the process here. See the quote here:
No no no. Don’t use kill -9. It doesn’t give the process a chance to cleanly:
- shut down socket connections
- clean up temp files
- inform its children that it is going away
- reset its terminal characteristics