Installing pgdevops for PostgreSQL on a Mac

How to setup the pgdevops web application on a Mac

I’ve been using BigSQL by OpenSCG for awhile now on my Windows development machine for a project I’m working on converting an application database from SQL Server to PostgreSQL. That is a wonderful environment as the installer sets up everything for you in one go. You get:

  1. A well-maintained distribution of PostgreSQL (pgsql from now on in this post)
  2. The wonderful pgdevops web application.
    • A dashboard and front-end for the pgc tool that OpenSCG provides as part of the BigSQL distro
      • PGC is a package management tool for pgsql, similar to apt for debian or yum for RPM-based linux distros.
    • Includes pgadmin4 , the web-based management and programming utility for pgsql.

On Windows, you’re ready to go. On Mac the story isn’t so great.

Based on the installation instruction page for macOS it would appear that everything gets installed:

But reality is this:

So how do we go about installing the BigSQL Manager/pgdevops app? I’m glad you asked.

Setup prerequisites

Open up your favorite terminal client1, you’re going to need it.

Get a git client

You’re going to need git. It is built in to macOS or you can upgrade to the command-line client from from git-scm.org if you choose. Or grab SourceTree, a nice GUI client for git, from Atlassian because we need to clone the pgdevops repo.

Get virtualenvwrapper

To run the pgdevops web app we need to use the tools for virtualenv called virtualenvwrapper. Following the instructions on the linked page for virtualenvwrapper we see this paragraph:

First, some initialization steps. Most of this only needs to be done one time. You will want to add the command to source /usr/local/bin/virtualenvwrapper.sh to your shell startup file, changing the path to virtualenvwrapper.sh depending on where it was installed by pip or your package manager.

On my Mac I added the following line to .bashrc in my home folder:

/Library/Frameworks/Python.framework/Versions/2.7/bin/virtualenvwrapper.shThis is where pip installed the wrapper shell script for me. Save this step until after you install virtualenvwrapper.

Install virtualenvwrapper by running the following at the command line: pip install virtualenvwrapper. That will install it and all of it’s dependencies. Make sure to grab the location it was installed and update your .bashrc. After updating .bashrc restart your terminal app to finish the virtualenvwrapper setup (which happens automatically the first time you start the terminal after updating .bashrc).

Create the virtualenv used for pgdevops

Now that we’ve got virtualenv/virtualenvwrapper set up run the following command:

mkvirtualenv devops-env

Get required Mac dependencies for pgdevops

In your virtual Python environment run:

pip install -r mac-requirements.txtIf you are coming back to the setup and aren’t yet in a virtual Python environment run the following:

workon devops-envGet Flask dependencies

pgdevops is a Flask-based app (a lightweight Python web framework). Unfortunately it would appear the file mac-requirements.txt, which is needed when installing pgdevops on a mac does not contain the full list of Flask dependencies the application needs. You can either add them to the mac-requirements.txt file once you’ve cloned the pgdevops repository or you can run the individual pip commands first. There is also a depedency on the backports.csv library. In terminal run:

pip install flask-htmlminpip install flask_paranoidpip install flask_migratepip install backports.csvSet up required environment variables

Assuming you ran the BigSQL installer already and have a working pgsql installation you need to set the following two environment variables based on that location (on my system I installed to $HOME/PostgreSQL.

export PGC_HOME="$HOME/PostgreSQL"export PGC_LOGS="$PGC_HOME/logs/pgcli_log.out"Get the pgdevops source code and set up

Clone the pgdevops repo

Now we’re ready to clone the repository and run the setup. From this page get the clone url (SSH or HTTPS) and clone the pgdevops repo to your local drive.

Setup pgdevops

Finally we’re ready to set up pgdevops. From the directory where you have the cloned source for pgdevops run:

python pgadmin/setup.pyRun pgdevops

After the install is complete you can run pgdevops with:

./bin/start_crossbar.sh Connect to the main page at http://localhost:8051

  1. My favorite is iTerm2