New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop brew services postgresql from running locally #1548

Merged
merged 1 commit into from Jan 3, 2019

Conversation

2 participants
@chrisgilmerproj
Copy link
Contributor

chrisgilmerproj commented Jan 3, 2019

Description

It sometimes happens that brew is running postgresql locally as a service and it interferes with the docker container running postgresql because they both are listening on localhost on port 5432. This turns out to be pretty hard to debug because we so rarely expect brew to be the issue. This PR quietly stops the brew postgresql process whenever the docker posgres service is run or reset.

Setup

First start the brew service:

brew services run postgresql
==> Successfully ran `postgresql` (label: homebrew.mxcl.postgresql)

Then run the docker psql container:

make db_run
brew services stop postgresql 2> /dev/null || true
Stopping `postgresql`... (might take a while)
Starting the local docker database container...
# The version of the postgres container should match production as closely
# as possible.
# https://github.com/transcom/ppp-infra/blob/7ba2e1086ab1b2a0d4f917b407890817327ffb3d/modules/aws-app-environment/database/variables.tf#L48
docker start db-dev || \
                docker run --name db-dev \
                        -e \
                        POSTGRES_PASSWORD=mysecretpassword \
                        -d \
                        -p 5432:5432 \
                        postgres:10.5
db-dev

This will also get called on make db_dev_reset because that will call make db_destroy db_run db_dev_create and the db_run step will catch the brew service running.

Code Review Verification Steps

  • Request review from a member of a different team.

@chrisgilmerproj chrisgilmerproj self-assigned this Jan 3, 2019

@chrisgilmerproj chrisgilmerproj requested review from akostibas and kimallen Jan 3, 2019

@@ -215,6 +215,9 @@ e2e_clean:
docker rm -f e2e_migrations || true

db_run:
ifndef CIRCLECI
brew services stop postgresql 2> /dev/null || true

This comment has been minimized.

@kimallen

kimallen Jan 3, 2019

Contributor

What does the 2> /dev/null mean?

This comment has been minimized.

@chrisgilmerproj

chrisgilmerproj Jan 3, 2019

Contributor

2 is the stderr stream (whereas 1 is stdout). So with that line I'm directing the output of stderr to /dev/null` so its silent when it fails. I expect it to fail all the time and I did not want confusing error messages cluttering up the log output.

@kimallen
Copy link
Contributor

kimallen left a comment

You're so fast! Worked for me!

@chrisgilmerproj chrisgilmerproj merged commit e89ece7 into master Jan 3, 2019

12 checks passed

ci/circleci: acceptance_tests Your tests passed on CircleCI!
Details
ci/circleci: build_app Your tests passed on CircleCI!
Details
ci/circleci: build_migrations Your tests passed on CircleCI!
Details
ci/circleci: build_tools Your tests passed on CircleCI!
Details
ci/circleci: client_test Your tests passed on CircleCI!
Details
ci/circleci: integration_tests_mymove Your tests passed on CircleCI!
Details
ci/circleci: integration_tests_office Your tests passed on CircleCI!
Details
ci/circleci: integration_tests_tsp Your tests passed on CircleCI!
Details
ci/circleci: pre_deps_golang Your tests passed on CircleCI!
Details
ci/circleci: pre_deps_yarn Your tests passed on CircleCI!
Details
ci/circleci: pre_test Your tests passed on CircleCI!
Details
ci/circleci: server_test Your tests passed on CircleCI!
Details

@chrisgilmerproj chrisgilmerproj deleted the cg_stop_brew_psql branch Jan 3, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment