Skip to content
This repository was archived by the owner on Jun 19, 2025. It is now read-only.

Commit 8d71774

Browse files
authored
have to move db connection back to where the connection is actually needed (#170)
* have to move db connection back to where it's needed. Otherwise idling connections will be timed out on PostgreSQL
1 parent 6001240 commit 8d71774

File tree

7 files changed

+19
-10
lines changed

7 files changed

+19
-10
lines changed

lib/pushmi_pullyu/aip/downloader.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ def make_file_set_directories(file_set_uuid)
151151

152152
def clean_directories
153153
return unless File.exist?(@aip_directory)
154+
154155
PushmiPullyu.logger.debug("#{@noid}: Nuking directories ...")
155156
FileUtils.rm_rf(@aip_directory)
156157
end

lib/pushmi_pullyu/aip/fedora_fetcher.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def download_object(download_path, url_extra: nil,
4646
return true
4747
elsif response.is_a?(Net::HTTPNotFound)
4848
raise FedoraFetchError unless optional
49+
4950
return false
5051
else
5152
raise FedoraFetchError

lib/pushmi_pullyu/aip/file_list_creator.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def extract_list_source_uuids
5353
break if next_proxy.nil?
5454

5555
raise NextPreviousProxyMismatch if this_proxy != find_prev_proxy(next_proxy)
56+
5657
this_proxy = next_proxy
5758
end
5859

@@ -76,6 +77,7 @@ def find_first_proxy
7677
first_uri = statement.object
7778
# Validate that the first proxy doesn't have a previous one
7879
raise FirstProxyHasPrev, @uri.to_s if find_prev_proxy(first_uri)
80+
7981
return first_uri
8082
end
8183
raise NoFirstProxyFound, @uri.to_s
@@ -86,6 +88,7 @@ def find_last_proxy
8688
last_uri = statement.object
8789
# Validate that the last proxy doesn't have a next one
8890
raise LastProxyHasNext, @uri.to_s if find_next_proxy(last_uri)
91+
8992
return last_uri
9093
end
9194
raise LastProxyFound, @uri.to_s

lib/pushmi_pullyu/aip/owner_email_editor.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ def initialize(rdf_string)
1111
end
1212

1313
def run
14+
setup_db_connection
1415
is_modified = false
1516
prefixes = nil
1617
# Read once to load prefixes (the @things at the top of an n3 file)
@@ -32,7 +33,18 @@ def run
3233
end
3334
end
3435
return new_body if is_modified
36+
3537
raise NoOwnerPredicate
3638
end
3739

40+
private
41+
42+
def setup_db_connection
43+
ActiveRecord::Base.establish_connection(database_configuration)
44+
end
45+
46+
def database_configuration
47+
PushmiPullyu.options[:database][:url]
48+
end
49+
3850
end

lib/pushmi_pullyu/cli.rb

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ def start_server
4848
setup_signal_traps
4949

5050
setup_log
51-
setup_db_connection
5251
print_banner
5352

5453
run_tick_loop
@@ -276,12 +275,4 @@ def start_server_as_daemon
276275
end
277276
end
278277

279-
def setup_db_connection
280-
ActiveRecord::Base.establish_connection(database_configuration)
281-
end
282-
283-
def database_configuration
284-
PushmiPullyu.options[:database][:url]
285-
end
286-
287278
end

lib/pushmi_pullyu/preservation_queue.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def wait_next_item
6363
while PushmiPullyu.continue_polling?
6464
element = next_item
6565
return element if element.present?
66+
6667
sleep @poll_interval
6768
end
6869
end

lib/pushmi_pullyu/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module PushmiPullyu
2-
VERSION = '1.0.4'.freeze
2+
VERSION = '1.0.5'.freeze
33
end

0 commit comments

Comments
 (0)