Skip to content

Commit

Permalink
Merge pull request QueueClassic#56 from glenngillen/master
Browse files Browse the repository at this point in the history
Lazy evaluate database URL
  • Loading branch information
♠ ace hacker committed Apr 11, 2012
2 parents 6057420 + 2629f2a commit 0ac05e5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 0 additions & 5 deletions lib/queue_classic.rb
Expand Up @@ -18,11 +18,6 @@ module QC
SqlFunctions = File.join(QC::Root, "/sql/ddl.sql") SqlFunctions = File.join(QC::Root, "/sql/ddl.sql")
DropSqlFunctions = File.join(QC::Root, "/sql/drop_ddl.sql") DropSqlFunctions = File.join(QC::Root, "/sql/drop_ddl.sql")


DB_URL =
ENV["QC_DATABASE_URL"] ||
ENV["DATABASE_URL"] ||
raise(ArgumentError, "missing QC_DATABASE_URL or DATABASE_URL")

# You can use the APP_NAME to query for # You can use the APP_NAME to query for
# postgres related process information in the # postgres related process information in the
# pg_stat_activity table. Don't set this unless # pg_stat_activity table. Don't set this unless
Expand Down
6 changes: 5 additions & 1 deletion lib/queue_classic/conn.rb
Expand Up @@ -84,7 +84,11 @@ def connect
end end


def db_url def db_url
URI.parse(DB_URL) return @db_url if @db_url
url = ENV["QC_DATABASE_URL"] ||
ENV["DATABASE_URL"] ||
raise(ArgumentError, "missing QC_DATABASE_URL or DATABASE_URL")
@db_url = URI.parse(url)
end end


def log(msg) def log(msg)
Expand Down

0 comments on commit 0ac05e5

Please sign in to comment.