Skip to content

Instantly share code, notes, and snippets.

@kattak
Last active July 9, 2017 21:25
Show Gist options
  • Save kattak/aa321a14e706cc1f3ea14e2d44564da1 to your computer and use it in GitHub Desktop.
Save kattak/aa321a14e706cc1f3ea14e2d44564da1 to your computer and use it in GitHub Desktop.

#postgres issues after computer shut down (or brew update, or sniffing the wind)

##Error Message:

could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "pool"=>5, "database"=>"hacker_klone_development"}

##problem: old psql running in background, causing issues -or- computer using other version of psql installed

##Steps:

  • remove old pid file
rm /usr/local/var/postgres/postmaster.pid

(pid is preventing postgres from starting up) (pid is recreated everytime psql starts)

  • restart pg
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start

How to understand what -D and -l mean?

  pg_ctl --help
  • -D location of database storage area

  • -l write (or append) server log to FILENAME

———— also, try

uninstalling pg:

gem uninstall pg 

then, installing the version you need bundle (inside directory)


##How to check if psql is running?

crud-and-rest-checkpoint-challenge :> ps aux | grep postgres
katkat          26928   0.0  0.0  2423356    196 s001  R+    7:28PM   0:00.00 grep postgres

#Shotgun issues Fixing Shotgun Server Issues ########################################################################################## ##HOW TO FIX SHOTGUN SERVER ISSUES (see example below)

(0 - Cause) Exiting iTerm with server still running leads to phantom ruby/sinatra/rails whatever processes

(1) Go to Activity Monitor and kill any ruby processes

(2) Try finding it and killing it (NB: are you finding a port, process, or both? I think both.)

$ ps aux | grep shotgun

$ ps aux | grep ruby

Sample printout:

11152 s000 R+ 0:00.00 grep shotgun

10766 s001 S+ 0:00.60 /Users/ryandeussing/.rvm/gems/ruby-1.9.3-p429@sinatra/bin/shotgun

Then kill it with:

kill -9 10766

(3) Manually set port for shotgun

Example:

$ be shotgun -p 3000

#####EXAMPLE:

Jin & K\atrina DeVaney (pair-jindigiordano,kattak *) ~/Desktop/craigslist-jr-challenge

$ be shotgun config.ru

== Shotgun/Thin on http://127.0.0.1:9393/

Thin web server (v1.7.0 codename Dunder Mifflin)

Maximum connections set to 1024

Listening on 127.0.0.1:9393, CTRL+C to stop

bundler: failed to load command: shotgun (/Users/apprentice/.rbenv/versions/2.3.1/bin/shotgun)

RuntimeError: no acceptor (port is in use or requires root privileges)

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