dblink 0.2 → 0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3b0e7af330863d700229caf232c3c2ae55931b42
4
- data.tar.gz: bb6ab4186a21d60076e51bd484ffc3f2be908b9a
3
+ metadata.gz: 456b57a2e4619b08713f7921299b7046a5750649
4
+ data.tar.gz: c704b0a9743500ac4f421452ea9eae534fdde7b6
5
5
  SHA512:
6
- metadata.gz: 4316a3ab2414ee53970ef3a21c49996448f93744e2d9d720f332bfaa9202d872568b32b447ae2044a064b15453371cdc96226e453f83c8e618741b7eb79b7058
7
- data.tar.gz: ecbb1c23a0b4aac78ebe3358cd4f5af84420e767392a7c0be7db375c5fc4dc60c38cff05e8cf1a8aab26880cc932d04fe36920d02d96b04d3dbe56430b4d120c
6
+ metadata.gz: 9d3e6b98eaf0977bea19f4c88b131c70a0655459462dc1d9bf8b6e7fc9174f2b32538f778a2088b69bb41a2af40ad0524bb4430e5db2ee119b37a51bb2f81f88
7
+ data.tar.gz: 3387240003ec5445e121f69ee031d99309038c1c7413e4c8203e412e4b673ec1bb8db77b2ef9495544eeeebaa42050cf98c21a1c11f51bbd2066e46ac7b2062e
data/bin/dblink CHANGED
@@ -110,6 +110,16 @@ if CLI_OPTS[:verbose]
110
110
  puts "Config folder: #{pgb_runner.tmp_folder}"
111
111
  end
112
112
 
113
+ pgb_runner_at_exit = Proc.new do
114
+ print "Stoping pgbouncer ..."
115
+ pgb_runner.stop_async
116
+ puts
117
+ end
118
+
119
+ at_exit do
120
+ pgb_runner_at_exit.call
121
+ end
122
+
113
123
  print "Starting pgbouncer "
114
124
  pgb_runner.run_async
115
125
  pgb_pid = pgb_runner.wait_for_pid
@@ -117,6 +127,23 @@ puts "- " + "OK".green + " (pid: #{pgb_pid})"
117
127
 
118
128
  print "Starting SSH tonnel "
119
129
  tonnel = TonnelRunner.new(pgb_runner.pgb_port, tmp_dir: pgb_runner.tmp_folder, verbose: CLI_OPTS[:verbose])
130
+
131
+ tonnel_at_exit = Proc.new do
132
+ print "Stoping ssh ..."
133
+ tonnel.stop_async
134
+ puts
135
+
136
+ tonnel.runner_thread.kill
137
+
138
+ puts "Removing tmp dir ..."
139
+ FileUtils.rm_rf(pgb_runner.tmp_folder)
140
+ end
141
+
142
+ at_exit do
143
+ pgb_runner_at_exit.call
144
+ tonnel_at_exit.call
145
+ end
146
+
120
147
  tonnel.run_async
121
148
  tonnel.wait_remote_port_allocated
122
149
 
@@ -168,18 +195,11 @@ if web_response['status'] == 'success'
168
195
  end
169
196
 
170
197
  at_exit do
171
- print "Stoping pgbouncer ..."
172
- pgb_runner.stop_async
173
- puts
174
- print "Stoping ssh ..."
175
- tonnel.stop_async
176
- puts
198
+ pgb_runner_at_exit.call
199
+ tonnel_at_exit.call
177
200
 
178
201
  tonnel.runner_thread.kill
179
202
 
180
- puts "Removing tmp dir ..."
181
- FileUtils.rm_rf(pgb_runner.tmp_folder)
182
-
183
203
  exit!
184
204
  end
185
205
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "dblink"
3
- s.version = "0.2"
3
+ s.version = "0.3"
4
4
  s.author = ["Pavel Evstigneev"]
5
5
  s.description= "CLI utility to share access to your local PostgreSQL server"
6
6
  s.email = ["pavel.evst@gmail.com"]
@@ -117,7 +117,7 @@ class PgBouncerRunner
117
117
 
118
118
  private
119
119
  def render_template(file, params)
120
- erb = ERB.new(File.read(file))
120
+ erb = ERB.new(File.read(BASE_DIR + '/' + file))
121
121
  erb.filename = file
122
122
  erb.result(binding)
123
123
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dblink
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.2'
4
+ version: '0.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Evstigneev