publish_to_web 2.2.3 → 2.2.4

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: 70394ab03d24060bbadf5cf70f3aa2bccd50ccde
4
- data.tar.gz: 04389aaecc439612dea87762d5a5281e72f37b30
3
+ metadata.gz: af20d39a6389731ea92171a36742afcfe9d8463e
4
+ data.tar.gz: d6f36d48e84d510f2cb22f8c08ff37ccc607bca9
5
5
  SHA512:
6
- metadata.gz: ced2bbe8126a04482a4aa9a7e3eb91c5bc9e3204a0382fc792cd57838cfb2102fb5be7b50662c154fa97fc1b280a18eb8fb8023cedc4d0150ac4e2e88a3e298c
7
- data.tar.gz: 9a07f7211592228b59620dab449318df1925a3df5a2d0df82806a42cd9386407c7af717e459a3a70e3514dbed9bd714091f1bc15a0f27607590d7be5a5075374
6
+ metadata.gz: 9f4da0373aacaca26d89457a39658fa3d744b44a35d1d71015fa764e45c35e77c9d9a3f2001a4676a2ca17a6bb498e980129a87780ca8356d38a3fddfd417b47
7
+ data.tar.gz: b1da80d1eec22a95212c34bd1a86f6d1268a3a99373c2ddf9eb50f9351a913c677888587b5746ef70a318e1a33b06b41c70aa34b03eda637ca9be64b915f58e8
@@ -60,13 +60,15 @@ class PublishToWeb
60
60
  logger.info "Checking if local backend is available at #{bind_host}:#{forward_port}"
61
61
  TCPSocket.new(bind_host, forward_port).close
62
62
 
63
- rescue Errno::ECONNREFUSED => err
63
+ rescue Errno::ECONNREFUSED
64
64
  logger.warn "Local backend is not available (yet?) - waiting for it to become available"
65
65
  sleep 5
66
66
  check_local_endpoint
67
67
  end
68
68
 
69
- def prepare_directory
69
+ def prepare_directory(fail_gracefully = true)
70
+ config.success = config.error = nil
71
+
70
72
  if node_name = config.node_name
71
73
  unless ["#{node_name}", "#{node_name}.protonet.info"].include? directory.node_name
72
74
  directory.set_node_name node_name
@@ -74,39 +76,46 @@ class PublishToWeb
74
76
  end
75
77
  directory.set_version
76
78
  directory.public_key
79
+
80
+ config.success = 'directory_configured'
81
+ rescue PublishToWeb::Directory::HttpResponseError => err
82
+ logger.warn "#{err.class}: #{err}"
83
+ logger.warn "Failed to interact with directory, will try again in a bit"
84
+
85
+ # Write out that we have an issue since the directory might refuse
86
+ # our license, our chosen node name might be in conflict and so on
87
+ config.error = "directory_failure.#{err.response.status.to_i}"
88
+
89
+ raise unless fail_gracefully
77
90
  end
78
91
 
79
- def start_tunnel
80
- config.success = config.error = nil
92
+ def stop_tunnel
93
+ tunnel.stop
94
+ @thread.try :join
95
+ end
81
96
 
82
- prepare_directory
83
- config.success = 'directory_configured'
97
+ def start_tunnel(blocking = true)
98
+ unless blocking
99
+ @thread = Thread.new start_tunnel true
100
+ return
101
+ end
84
102
 
103
+ prepare_directory false
85
104
  check_local_endpoint
86
105
 
87
106
  logger.info "Starting tunnel to #{proxy_host} as #{directory.node_name}"
88
- tunnel.start do
89
- config.success = "connection_established"
90
- end
107
+ tunnel.start { config.success = "connection_established" }
91
108
 
92
109
  rescue Net::SSH::AuthenticationFailed => err
93
110
  logger.warn "#{err.class}: #{err}"
94
111
  logger.warn "Probably the SSH key is not deployed on the proxy server yet, retrying in a bit"
95
112
 
96
113
  sleep 30
97
- start_tunnel
114
+ retry
98
115
 
99
116
  rescue PublishToWeb::Directory::HttpResponseError => err
100
- logger.warn "#{err.class}: #{err}"
101
- logger.warn "Failed to interact with directory, will try again in a bit"
102
-
103
- # Write out that we have an issue since the directory might refuse
104
- # our license, our chosen node name might be in conflict and so on
105
- config.success = nil
106
- config.error = "directory_failure.#{err.response.status.to_i}"
107
-
108
117
  sleep 30
109
- start_tunnel
118
+ retry
110
119
  end
111
120
 
112
121
  private
@@ -40,6 +40,10 @@ class PublishToWeb
40
40
  end
41
41
  end
42
42
 
43
+ def stop
44
+ @running = false
45
+ end
46
+
43
47
  def start
44
48
  Net::SSH.start proxy_host, proxy_user, ssh_options do |ssh|
45
49
  ssh.forward.remote forward_port, bind_host, remote_port do |real_remote_port|
@@ -53,7 +57,9 @@ class PublishToWeb
53
57
  end
54
58
 
55
59
  logger.info "Entering keepalive loop"
56
- ssh.loop { true } # do not remove this block, documentation is broken
60
+
61
+ @running = true
62
+ ssh.loop { @running }
57
63
  end
58
64
  end
59
65
  end
@@ -1,3 +1,3 @@
1
1
  class PublishToWeb
2
- VERSION = "2.2.3"
2
+ VERSION = "2.2.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: publish_to_web
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.3
4
+ version: 2.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christoph Olszowka
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-05-12 00:00:00.000000000 Z
11
+ date: 2016-05-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-ssh