pry-remote-em 0.7.5 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9891306377f0196004da3a9bd1c69beb92d49756
4
+ data.tar.gz: d09d7572adf27c19d9b8f8fdf69290c4dc25264e
5
+ SHA512:
6
+ metadata.gz: b15649c543deaa0b4e48fdb3ec1f8db2b7296709c50c62ac1e6e69f2b2cbf4abcaf3af61ca9270a7c850422f9afd940cd9fc38a5b2a3bfdd506e12f5bf0600ae
7
+ data.tar.gz: e15c4019739eef9f214a63c6b064ca33564a12f8051da4cf25889885cfa31fca497c23b4a22110bbcb3d5a6bc15b9bbc4ed61dce7ce83ef85c5f233f1ea39c70
@@ -0,0 +1,140 @@
1
+ # 1.0.0
2
+
3
+ ## Breaking changes
4
+
5
+ * **BREAKING CHANGE** Change `!` and `!!` messaging commands to `^` and `^^` to avoid confusing with Pry's built in `!` command and Ruby's `not` semantics
6
+ * **BREAKING CHANGE** Change `PryRemoteEm::Server.run` method signature to hash-only form (`remote_pry_em` method's signature didn't changed)
7
+ * **BREAKING CHANGE** Change `allow_shell_cmds` setting to `true` by default instead of `false`, because most of projects does not use $SAFE and any shell command can be run from Ruby code with `system` call or backticks, so this option is illusion in most cases
8
+ * **BREAKING CHANGE** `PryRemoteEm::Server.run` returns whole server description instead of URL
9
+ * **BREAKING CHANGE** Rename public constants to avoid confusing
10
+ * **BREAKING CHANGE** Drop support for eventmachine prior to 1.0.0.beta4
11
+
12
+ ## Features
13
+
14
+ * Add `PryRemoteEm::Sandbox` as target by default, see Readme for details
15
+ * Add proxy-by-default setting to CLI
16
+ * Add possibility to use environment variables on CLI connection
17
+ * Add more environment variables to control server without code changing (described in readme)
18
+ * Add support for empty environment variables and nil arguments on server start
19
+ * Add possibility to set external url for server (to use lib with NAT or Docker) using `PRYEMURL` or `external_url` option
20
+ * Add ability to use custom server name using `PRYEMNAME` environment variable or `name` option (and displaying it in the prompt)
21
+ * Add ability to start server without starting broker using `PRYEMREMOTEBROKER` environment variable or `remote_broker` option
22
+ * Add `pry-remote-em-broker` binary to start broker without starting server
23
+ * Add `Object#pry_remote_em` alias to `Object#remote_pry_em` to avoid common confusing
24
+ * Add support for options hash as first argument instead of third in `Object#remote_pry_em`
25
+ * Add local history loading on session start
26
+ * Add support for `pry-coolline` (just install this gem to make it work)
27
+ * Add support for several URIs per one server (when binding to 0.0.0.0)
28
+ * Add option to ignore localhost urls in the list (useful when server binding to 0.0.0.0 in Docker, where localhost is useless)
29
+ * Add support for `details` option on server start and corresponding CLI option to display some usefull information about server instead or url in broker table (for example, health status, which can be updated on every heartbeat via details hash mutating)
30
+
31
+ ## Fixes
32
+
33
+ * Fix proxy, it didn't work at all
34
+ * Fix interative shell commands, they didn't work at all
35
+ * Fix `libc++abi.dylib: Pure virtual function called!` error on client disconnecting
36
+ * Fix strange buffer bugs on long output over network using MessagePack protocol instead of JSON
37
+ * Fix console crash on pager quit
38
+ * Fix console crash on Ctrl+C (now it's clears the buffer like in native Pry)
39
+ * Fix IPv6 localhost crash
40
+ * Fix missing requires when using broker without server
41
+ * Fix port access check when using environment variables
42
+ * Fix strange effects when registering in broker from Docker (now broker use UUID as a key instead of URI)
43
+ * Fix message `broker connection unbound starting a new one` on EventMachine stopping
44
+ * Fix unregistering in broker by timeout only, now servers unregister instantly after closing connection
45
+ * Fix interative shell commands echo printing
46
+ * Fix unknown shell command problem (now valid `command not found` message is printing)
47
+ * Fix behaviour on empty input, now it's exactly like as in native Pry
48
+ * Fix saving empty strings in history
49
+
50
+ ## Chore
51
+
52
+ * Add ruby-termios to runtime dependencies to avoid confusing `unable to load keyboard dependencies` message
53
+ * Bump dependencies versions
54
+ * Remove useless return values from inner methods
55
+ * Add stable 3 seconds timeout on broker reconnection, not random one
56
+ * Require `pry-remote-em/server` by defaults
57
+ * Correct README for default broker port
58
+ * Use single quotes by default
59
+ * Use Ruby 1.9 hash syntax by default
60
+ * Use semantic versioning, starting at 1.0.0 (since we're using it in production for a long time already)
61
+
62
+ # 0.7.5
63
+
64
+ * [#42](https://github.com/gruis/pry-remote-em/pull/42) - Use bytesize String method instead of length in protocol. [distorhead](https://github.com/distorhead)
65
+
66
+ # 0.7.4
67
+
68
+ * [#40](https://github.com/gruis/pry-remote-em/pull/40) - require 'pry', not its parts [rking](https://github.com/rking)
69
+ * [#39](https://github.com/gruis/pry-remote-em/pull/39) - stagger_output needs Pry::Pager to be loaded in the parent scope [pcmantz](https://github.com/pcmantz)
70
+
71
+ # 0.7.3
72
+
73
+ * Broker listens at 6462 everything else starts at 6463
74
+ * cli assumes port 6462 when not specified
75
+
76
+ # 0.7.2
77
+
78
+ * Broker.run yields to a block when broker connection has been established
79
+
80
+ # 0.7.1
81
+
82
+ * server list can be filtered by host, port, name, or SSL support
83
+ * server list can be sorted by host, port, name, or SSL support
84
+ * cli assumes port 6461 when not specified
85
+ * cli accepts -c and -p options to immediately connect or proxy from the broker to a server matching the name specified on the command line
86
+ * closes #37 loosens pry version requirement
87
+ * client sorts server list by host address
88
+ * when registering 0.0.0.0 with a Broker register each interface instead
89
+
90
+ # 0.7.0
91
+
92
+ * fixes #21 version matching between client and server allow differences in patch levels
93
+ * fixes #31 client reports own version when incompatible with server
94
+ * client supports vi mode: rb-readline replaced by readline
95
+ * fixes #31 termios is no longer a hard requirement: shell commands will be disabled without it
96
+ * adds PryRemoteEm.servers and PryRemoteEm.stop_server
97
+ * broker can proxy requests to local or remote servers that have registered with it
98
+ * closes #11 all servers will attempt to register with a broker; client will retrieve list of servers from the broker and present a menu to the user by default
99
+ * when specifying a specific port to listen on the option :port_fail can be set to :auto; if binding fails attempt to bind on the next port
100
+ * server.run returns a url (String) with the scheme, host and port of the listening server
101
+ * json specific parts of wire protocol are abstracted away from client and server
102
+ * json proto is a bit more robust: delimeter can be a part of data and CRC is performed
103
+
104
+ # 0.6.2
105
+
106
+ * handle reset command appropriately
107
+
108
+ # 0.6.1
109
+
110
+ * messages are tagged with user that sent them if authentication is being used
111
+
112
+ # 0.6.0
113
+
114
+ * adds shell command support
115
+ * adds auth event callbacks
116
+ * adds configurable logger
117
+
118
+ # 0.5.0
119
+
120
+ * adds simple messaging with '!' and '!!'
121
+
122
+ # 0.4.3
123
+
124
+ * fixes https://github.com/gruis/pry-remote-em/issues/26
125
+ * fixes https://github.com/gruis/pry-remote-em/issues/24
126
+
127
+ # 0.4.2
128
+
129
+ * fixes https://github.com/gruis/pry-remote-em/issues/23
130
+
131
+ # 0.4.1
132
+
133
+ * empty lines don't cause termination
134
+
135
+ # 0.4.0
136
+
137
+ * User/Pass authentication
138
+ * TLS support
139
+ * Paging support
140
+ * Tab completion
data/README.md CHANGED
@@ -28,13 +28,13 @@ class Foo
28
28
  end
29
29
  end
30
30
 
31
- EM.run { Foo.new 10, 20 }
31
+ EM.run { Foo.new 10, 20 }
32
32
  ```
33
33
 
34
34
  Running it will print out a message telling you Pry is waiting for a
35
35
  program to connect itself to it:
36
36
 
37
- [pry-remote-em] listening for connections on pryem://localhost:6462/
37
+ [pry-remote-em] listening for connections on pryem://127.0.0.1:6462/
38
38
 
39
39
  You can then connect to the pry session using ``pry-remote-em``:
40
40
 
@@ -88,7 +88,7 @@ or even in the same process. When you start the service via
88
88
  will automatically take the next free port from 6462.
89
89
 
90
90
  ```ruby
91
- require "pry-remote-em/server"
91
+ require 'pry-remote-em/server'
92
92
 
93
93
  os = ObjectSpace.each_object
94
94
  expose = []
@@ -97,9 +97,9 @@ while expose.length < 5
97
97
  expose.push(o) unless o.frozen?
98
98
  end
99
99
 
100
- EM.run {
100
+ EM.run do
101
101
  expose.each {|o| o.remote_pry_em('localhost', :auto) }
102
- }
102
+ end
103
103
  ```
104
104
 
105
105
  $ ruby test/auto-demo.rb
@@ -114,12 +114,12 @@ EM.run {
114
114
  $ pry-remote-em pryem://127.0.0.1:6462/
115
115
  [pry-remote-em] client connected to pryem://127.0.0.1:6462/
116
116
  [pry-remote-em] remote is PryRemoteEm 0.4.0 pryem
117
- [1] pry("pretty_print")>
117
+ [1] pry("pretty_print")>
118
118
 
119
119
  $ pry-remote-em pryem://127.0.0.1:6463/
120
120
  [pry-remote-em] client connected to pryem://127.0.0.1:6463/
121
121
  [pry-remote-em] remote is PryRemoteEm 0.4.0 pryem
122
- [1] pry("pack")>
122
+ [1] pry("pack")>
123
123
 
124
124
  $ pry-remote-em pryem://127.0.0.1:6464/
125
125
  [pry-remote-em] client connected to pryem://127.0.0.1:6464/
@@ -129,22 +129,22 @@ $ pry-remote-em pryem://127.0.0.1:6464/
129
129
  $ pry-remote-em pryem://127.0.0.1:6465/
130
130
  [pry-remote-em] client connected to pryem://127.0.0.1:6465/
131
131
  [pry-remote-em] remote is PryRemoteEm 0.4.0 pryem
132
- [1] pry("to_json")>
132
+ [1] pry("to_json")>
133
133
 
134
134
  $ pry-remote-em pryem://127.0.0.1:6466/
135
135
  [pry-remote-em] client connected to pryem://127.0.0.1:6466/
136
136
  [pry-remote-em] remote is PryRemoteEm 0.4.0 pryem
137
- [1] pry(#<RubyVM::InstructionSequence>)>
137
+ [1] pry(#<RubyVM::InstructionSequence>)>
138
138
  ```
139
139
 
140
140
  ## Server Broker
141
141
 
142
142
  When more than one server is running on a given host and each server is
143
143
  started with :auto it can be time consuming to manually figure out which
144
- port each server is running on. The Broker which listens on port 6461
145
- keeps track of which server is running on which port.
144
+ port each server is running on. The Broker which listens on port 6462
145
+ keeps track of which server is running on which port.
146
146
 
147
- By default the pry-remote-em cli utility will connect to the broker and
147
+ By default the pry-remote-em cli utility will connect to the broker and
148
148
  retrieve a list of known servers. You can then select one to connect to
149
149
  by its id, name or url. You can also choose to proxy your connection
150
150
  through the broker to the selected server.
@@ -152,7 +152,7 @@ through the broker to the selected server.
152
152
  ```shell
153
153
 
154
154
  $ bin/pry-remote-em
155
- [pry-remote-em] client connected to pryem://127.0.0.1:6461/
155
+ [pry-remote-em] client connected to pryem://127.0.0.1:6462/
156
156
  [pry-remote-em] remote is PryRemoteEm 0.7.0 pryem
157
157
  -----------------------------------------------------------------------------
158
158
  | id | name | url |
@@ -176,15 +176,15 @@ connect to: 3
176
176
  [1] pry(#<#<Class:0x007f924b9bbee8>>)>
177
177
  ```
178
178
 
179
- By default the Broker will listen on 127.0.0.1:6461. To change the ip
179
+ By default the Broker will listen on 127.0.0.1:6462. To change the ip
180
180
  address that the Broker binds to specify it in a PRYEMBROKER environment
181
181
  variable, or in :broker_host option passed to #remote_pry_em.
182
182
 
183
183
  ```shell
184
184
 
185
- $ PRYEMBROKER=0.0.0.0 be ./test/service.rb
185
+ $ PRYEMBROKER=0.0.0.0 be ./test/service.rb
186
186
  I, [2012-07-13T21:10:00.936993 #88528] INFO -- : [pry-remote-em] listening for connections on pryem://0.0.0.0:6462/
187
- I, [2012-07-13T21:10:00.937132 #88528] INFO -- : [pry-remote-em broker] listening on pryem://0.0.0.0:6461
187
+ I, [2012-07-13T21:10:00.937132 #88528] INFO -- : [pry-remote-em broker] listening on pryem://0.0.0.0:6462
188
188
  I, [2012-07-13T21:10:00.937264 #88528] INFO -- : [pry-remote-em] listening for connections on pryem://0.0.0.0:1337/
189
189
  I, [2012-07-13T21:10:00.937533 #88528] INFO -- : [pry-remote-em] listening for connections on pryems://0.0.0.0:6463/
190
190
  I, [2012-07-13T21:10:00.937804 #88528] INFO -- : [pry-remote-em] listening for connections on pryems://0.0.0.0:6464/
@@ -194,15 +194,15 @@ I, [2012-07-13T21:10:00.938835 #88528] INFO -- : [pry-remote-em] listening for
194
194
  I, [2012-07-13T21:10:00.939230 #88528] INFO -- : [pry-remote-em] listening for connections on pryem://0.0.0.0:6468/
195
195
  I, [2012-07-13T21:10:00.939640 #88528] INFO -- : [pry-remote-em] listening for connections on pryem://0.0.0.0:6469/
196
196
  I, [2012-07-13T21:10:01.031576 #88528] INFO -- : [pry-remote-em broker] received client connection from 127.0.0.1:62288
197
- I, [2012-07-13T21:10:01.031931 #88528] INFO -- : [pry-remote-em] client connected to pryem://127.0.0.1:6461/
197
+ I, [2012-07-13T21:10:01.031931 #88528] INFO -- : [pry-remote-em] client connected to pryem://127.0.0.1:6462/
198
198
  I, [2012-07-13T21:10:01.032120 #88528] INFO -- : [pry-remote-em] remote is PryRemoteEm 0.7.0 pryem
199
- I, [2012-07-13T21:10:01.032890 #88528] INFO -- : [pry-remote-em broker] registered pryem://127.0.0.1:6462/ - "#<#<Class:0x007f924b9bbee8>>"
200
- I, [2012-07-13T21:10:01.125123 #88528] INFO -- : [pry-remote-em broker] registered pryem://127.0.0.1:6469/ - "#<#<Class:0x007f924b9bbee8>>"
199
+ I, [2012-07-13T21:10:01.032890 #88528] INFO -- : [pry-remote-em broker] registered pryem://127.0.0.1:6462/ - "#<#<Class:0x007f924b9bbee8>>"
200
+ I, [2012-07-13T21:10:01.125123 #88528] INFO -- : [pry-remote-em broker] registered pryem://127.0.0.1:6469/ - "#<#<Class:0x007f924b9bbee8>>"
201
201
  I, [2012-07-13T21:10:01.125487 #88528] INFO -- : [pry-remote-em broker] registered pryems://127.0.0.1:6467/ - "#<#<Class:0x007f924b9bbee8>>"
202
202
  I, [2012-07-13T21:10:01.490729 #88528] INFO -- : [pry-remote-em broker] registered pryems://127.0.0.1:6464/ - "#<#<Class:0x007f924b9bbee8>>"
203
- I, [2012-07-13T21:10:01.583015 #88528] INFO -- : [pry-remote-em broker] registered pryem://127.0.0.1:1337/ - "#<Foo>"
203
+ I, [2012-07-13T21:10:01.583015 #88528] INFO -- : [pry-remote-em broker] registered pryem://127.0.0.1:1337/ - "#<Foo>"
204
204
  I, [2012-07-13T21:10:01.674842 #88528] INFO -- : [pry-remote-em broker] registered pryems://127.0.0.1:6466/ - "#<#<Class:0x007f924b9bbee8>>"
205
- I, [2012-07-13T21:10:01.766813 #88528] INFO -- : [pry-remote-em broker] registered pryem://127.0.0.1:6468/ - "#<#<Class:0x007f924b9bbee8>>"
205
+ I, [2012-07-13T21:10:01.766813 #88528] INFO -- : [pry-remote-em broker] registered pryem://127.0.0.1:6468/ - "#<#<Class:0x007f924b9bbee8>>"
206
206
  I, [2012-07-13T21:10:01.858423 #88528] INFO -- : [pry-remote-em broker] registered pryems://127.0.0.1:6465/ - "#<#<Class:0x007f924b9bbee8>>"
207
207
  ```
208
208
 
@@ -211,7 +211,7 @@ running on a different host. Just specify the Brokers address in the
211
211
  PRYEMBROKER environment variable or the :broker_host option passed to #remote_pry_em.
212
212
 
213
213
  To connect to a broker running on a seperate host with the cli client
214
- just specify it on the command line ``bin/pry-remote-em preym://10.0.0.2:6461/``.
214
+ just specify it on the command line ``bin/pry-remote-em preym://10.0.0.2:6462/``.
215
215
  You can then proxy your client connections to remote servers through
216
216
  that Broker.
217
217
 
@@ -220,18 +220,18 @@ TLS enabled server.
220
220
 
221
221
 
222
222
  ## TLS Encryption
223
-
224
- When creating a server pass the :tls => true option to enable TLS.
223
+
224
+ When creating a server pass the tls: true option to enable TLS.
225
225
 
226
226
  ```ruby
227
- obj.remote_pry_em('localhost', :auto, :tls => true)
227
+ obj.remote_pry_em('localhost', :auto, tls: true)
228
228
  ```
229
229
 
230
- If you pass a Hash it will be used to configure the internal TLS handler.
230
+ If you pass a Hash it will be used to configure the internal TLS handler.
231
231
 
232
232
  ```ruby
233
- obj.remote_pry_em('localhost', :auto, :tls => {:private_key_file => '/tmp/server.key'})
234
- ```
233
+ obj.remote_pry_em('localhost', :auto, tls: { private_key_file: '/tmp/server.key' })
234
+ ```
235
235
  See [EventMachine::Connection#start_tls](http://eventmachine.rubyforge.org/EventMachine/Connection.html#M000296) for the available options.
236
236
 
237
237
 
@@ -244,7 +244,7 @@ $ pry-remote-em pryem://localhost:6462/
244
244
  [pry-remote-em] remote is PryRemoteEm 0.4.0 pryems
245
245
  [pry-remote-em] negotiating TLS
246
246
  [pry-remote-em] TLS connection established
247
- [1] pry(#<Hash>)>
247
+ [1] pry(#<Hash>)>
248
248
  ```
249
249
 
250
250
  To always require a TLS connection give pry-remote-em a pryem*s* URL. If
@@ -270,24 +270,24 @@ or any object that responds to #call.
270
270
 
271
271
  #### Auth with a Hash
272
272
  ```ruby
273
- auth_hash = {'caleb' => 'crane', 'john' => 'lowski'}
274
- obj = {:encoding => __ENCODING__, :weather => :cloudy}
275
- EM.run{
276
- obj.remote_pry_em('localhost', :auto, :tls => true, :auth => auth_hash)
277
- }
273
+ auth_hash = { 'caleb' => 'crane', 'john' => 'lowski' }
274
+ obj = { encoding: __ENCODING__, weather: :cloudy }
275
+ EM.run do
276
+ obj.remote_pry_em('localhost', :auto, tls: true, auth: auth_hash)
277
+ end
278
278
  ```
279
279
 
280
280
  #### Auth with a lambda
281
281
  ```ruby
282
282
  require 'net/ldap'
283
283
  ldap_anon = lambda do |user, pass|
284
- ldap = Net::LDAP.new :host => '10.0.0.1', :port => 389, :auth => {:method => :simple, :username => user, :password => pass}
284
+ ldap = Net::LDAP.new host: '10.0.0.1', port: 389, auth: { method: :simple, username: user, password: pass }
285
285
  ldap.bind
286
286
  end
287
- obj = {:encoding => __ENCODING__, :weather => :cloudy}
288
- EM.run{
289
- obj.remote_pry_em('localhost', :auto, :tls => true, :auth => ldap_anon)
290
- }
287
+ obj = { encoding: __ENCODING__, weather: :cloudy }
288
+ EM.run do
289
+ obj.remote_pry_em('localhost', :auto, tls: true, auth: ldap_anon)
290
+ end
291
291
  ```
292
292
 
293
293
  #### Auth with an object
@@ -301,10 +301,10 @@ class Authenticator
301
301
  end
302
302
  end
303
303
 
304
- obj = {:encoding => __ENCODING__, :weather => :cloudy}
305
- EM.run{
306
- obj.remote_pry_em('localhost', :auto, :tls => true, :auth => Authenticator.new(auth_hash))
307
- }
304
+ obj = { encoding: __ENCODING__, weather: :cloudy }
305
+ EM.run do
306
+ obj.remote_pry_em('localhost', :auto, tls: true, auth: Authenticator.new(auth_hash))
307
+ end
308
308
  ```
309
309
 
310
310
 
@@ -323,7 +323,7 @@ $ pry-remote-em pryems://localhost:6464/
323
323
  [pry-remote-em] TLS connection established
324
324
  user: caleb
325
325
  caleb's password: *****
326
- [1] pry(#<Hash>)>
326
+ [1] pry(#<Hash>)>
327
327
  ```
328
328
 
329
329
 
@@ -357,7 +357,7 @@ $ bin/pry-remote-em pryems:///
357
357
  [pry-remote-em] client connected to pryem://127.0.0.1:6462/
358
358
  [pry-remote-em] remote is PryRemoteEm 0.2.0 pryems
359
359
  [1] pry(#<Hash>)> key (^TAB ^TAB)
360
- key key? keys
360
+ key key? keys
361
361
  [1] pry(#<Hash>)> keys
362
362
  => [:encoding]
363
363
  ```
@@ -384,13 +384,285 @@ The standard Pry pager is supported through the included client.
384
384
  :
385
385
  ```
386
386
 
387
+ ## Sandbox
388
+
389
+ The `PryRemoteEm::Sandbox` class introduced to help in case when you
390
+ do not mush interested in console's executing context but just want to
391
+ access a remote server's "control panel" with usefull methods and
392
+ without worrying about breaking some object's internal state.
393
+
394
+ To use sandbox just run `PryRemoteEm::Server.run` instead of
395
+ `binding.remote_pry_em`. You can include any modules with your
396
+ application's business logic in this class to get real "control panel"
397
+ for your program.
398
+
399
+ The simple example:
400
+
401
+ ```ruby
402
+ # Microservice A, a.rb
403
+
404
+ require 'bundler'
405
+ Bundler.require
406
+
407
+ DB = Sequel.sqlite
408
+
409
+ module ControlPanel
410
+ def u(id)
411
+ DB[:users].find(id)
412
+ end
413
+
414
+ def ban(id)
415
+ DB[:users].where(id: id).update u(id).merge('status' => 'banned')
416
+ end
417
+ end
418
+
419
+ PryRemoteEm::Sandbox.include ControlPanel
420
+
421
+ EventMachine.run do
422
+ trap(:INT) { EventMachine.stop }
423
+
424
+ PryRemoteEm::Server.run name: 'Microservice A', port: :auto, remote_broker: true, details: { environment: 'staging' }
425
+ end
426
+ ```
427
+
428
+ ```ruby
429
+ # Microservice B, b.rb
430
+
431
+ require 'bundler'
432
+ Bundler.require
433
+
434
+ module Transport
435
+ # ...
436
+ end
437
+
438
+ module ControlPanel
439
+ def ping(microservice)
440
+ Transport.send_ping(microservice)
441
+ end
442
+ end
443
+
444
+ PryRemoteEm::Sandbox.include ControlPanel
445
+
446
+ EventMachine.run do
447
+ trap(:INT) { EventMachine.stop }
448
+
449
+ PryRemoteEm::Server.run name: 'Microservice B', port: :auto, remote_broker: true, details: { environment: 'staging' }
450
+ end
451
+ ```
452
+
453
+ Then, in shell:
454
+
455
+ ```shell
456
+ $ pry-remote-em-broker > /dev/null &
457
+ $ ruby a.rb > /dev/null &
458
+ $ ruby b.rb > /dev/null &
459
+ $
460
+ $ pry-remote-em -P --sn -d environment
461
+ [pry-remote-em] client connected to pryem://127.0.0.1:6462/
462
+ [pry-remote-em] remote is PryRemoteEm 1.0.0 pryem
463
+ ------------------------------------------
464
+ | | name | environment |
465
+ ------------------------------------------
466
+ | 1 | Microservice A | staging |
467
+ | 2 | Microservice B | staging |
468
+ ------------------------------------------
469
+ (q) to quit; (r) to refresh; (c) to connect without proxy
470
+ proxy to: 1
471
+ [pry-remote-em] remote is PryRemoteEm 1.0.0 pryem
472
+ [1] Microservice A (sandbox)> u 13
473
+ => {"id"=>13, "violations"=>4, "status"=>"active"}
474
+ [2] Microservice A (sandbox)> @my_bad_user = _
475
+ => {"id"=>13, "violations"=>4, "status"=>"active"}
476
+ [3] Microservice A (sandbox)> ban 13 # You can use control panel to work with some business cases
477
+ => 1
478
+ [4] Microservice A (sandbox)> exit
479
+ [pry-remote-em] session terminated
480
+ $
481
+ $ pry-remote-em pryem://127.0.0.1:6463
482
+ [pry-remote-em] remote is PryRemoteEm 1.0.0 pryem
483
+ [1] Microservice A (sandbox)> @my_bad_user
484
+ => {"id"=>13, "violations"=>4, "status"=>"banned"}
485
+ [2] Microservice A (sandbox)> exit
486
+ [pry-remote-em] session terminated
487
+ $
488
+ $ pry-remote-em pryem://127.0.0.1:6464
489
+ [pry-remote-em] remote is PryRemoteEm 1.0.0 pryem
490
+ [1] Microservice A (sandbox)> ping :A # Or you can use it to check infrastructure and perform custom communications between servers
491
+ => "pong"
492
+ [2] Microservice A (sandbox)> exit
493
+ [pry-remote-em] session terminated
494
+ ```
495
+
496
+ In sandbox you have those possibilities "out of the box":
497
+
498
+ * `puts`, `putc`, `print`, `p` and `pp` methods works almost as you
499
+ expected. In other contexts they will use server's STDOUT, but in
500
+ sandbox they will send all the data to client. Remember, you'll lost
501
+ those methods out of the sandbox context:
502
+
503
+ ```shell
504
+ $ pry-remote-em pryem://127.0.0.1:6463
505
+ [pry-remote-em] remote is PryRemoteEm 1.0.0 pryem
506
+ [1] Demo Server (sandbox)> puts 'Hello World' # It works!
507
+ Hello World
508
+ => nil
509
+ [2] Demo Server (sandbox)> Object.new.instance_eval { puts "Hello World" } # Do not work
510
+ => nil
511
+ [3] Demo Server (sandbox)> cd Object.new
512
+ [4] Demo Server (#<Object>):1> puts "Hello World" # Do not work
513
+ => nil
514
+ ```
515
+
516
+ * `any_errors?`, `last_error` and `last_errors` methods in sandbox
517
+ context with `PryRemoteEm::Sandbox.add_error` method from your code
518
+ to help you store all the bugs and debug it in the bug's execution
519
+ context. It also integrated with `wtf?` command. For example:
520
+
521
+ ```ruby
522
+ require 'bundler'
523
+ Bundler.require
524
+
525
+ def safe_handler(source_binding)
526
+ yield
527
+ rescue => exception
528
+ PryRemoteEm::Sandbox.add_error(exception, source_binding)
529
+ raise
530
+ end
531
+
532
+ def danger_mathod(a, b)
533
+ safe_handler(binding) do
534
+ a / b
535
+ end
536
+ end
537
+
538
+ EventMachine.run do
539
+ trap(:INT) { EventMachine.stop }
540
+
541
+ EventMachine.error_handler do |exception|
542
+ PryRemoteEm::Sandbox.add_error(exception)
543
+ end
544
+
545
+ EventMachine.add_timer(5) { danger_mathod 1, 0 }
546
+
547
+ PryRemoteEm::Server.run name: 'Demo Server', details: { hostname: 'local' }
548
+ end
549
+ ```
550
+
551
+ Then, in shell:
552
+
553
+ ```shell
554
+ $ pry-remote-em -P --sn -d hostname
555
+ [pry-remote-em] client connected to pryem://127.0.0.1:6462/
556
+ [pry-remote-em] remote is PryRemoteEm 1.0.0 pryem
557
+ ------------------------------------
558
+ | | name | hostname |
559
+ ------------------------------------
560
+ | 1 | Demo Server | local |
561
+ ------------------------------------
562
+ (q) to quit; (r) to refresh; (c) to connect without proxy
563
+ proxy to: 1
564
+ [pry-remote-em] remote is PryRemoteEm 1.0.0 pryem
565
+ [1] Demo Server (sandbox)> any_errors?
566
+ => true
567
+ [2] Demo Server (sandbox)> last_error
568
+ => #<ZeroDivisionError: divided by 0>
569
+ [3] Demo Server (sandbox)> wtf?
570
+ Exception: ZeroDivisionError: divided by 0
571
+ --
572
+ 0: demo_server.rb:13:in `/'
573
+ 1: demo_server.rb:13:in `block in danger_mathod'
574
+ 2: demo_server.rb:5:in `safe_handler'
575
+ 3: demo_server.rb:12:in `danger_mathod'
576
+ 4: demo_server.rb:24:in `block (2 levels) in <main>'
577
+ 5: /usr/local/lib/ruby/gems/2.4.0/gems/eventmachine-1.2.7/lib/eventmachine.rb:195:in `run_machine'
578
+ 6: /usr/local/lib/ruby/gems/2.4.0/gems/eventmachine-1.2.7/lib/eventmachine.rb:195:in `run'
579
+ 7: demo_server.rb:17:in `<main>'
580
+ [4] Demo Server (sandbox)> cd last_error.source_binding
581
+ [5] Demo Server (main):1> whereami
582
+
583
+ From: /Users/user/Projects/demo/demo_server.rb @ line 12 Object#danger_mathod:
584
+
585
+ 11: def danger_mathod(a, b)
586
+ => 12: safe_handler(binding) do
587
+ 13: a / b
588
+ 14: end
589
+ 15: end
590
+
591
+ [6] Demo Server (main):1> ls
592
+ self.methods: inspect to_s
593
+ locals: _ __ _dir_ _ex_ _file_ _in_ _out_ _pry_ a b
594
+ [7] Demo Server (main):1> a
595
+ => 1
596
+ [8] Demo Server (main):1> b
597
+ => 0
598
+ ```
599
+
600
+ * `server` method to access PryRemoteEm::Server description object.
601
+ For example, it can be useful for changing `details`:
602
+
603
+ ```ruby
604
+ require 'bundler'
605
+ Bundler.require
606
+
607
+ module HealthChecker
608
+ # ...
609
+ end
610
+
611
+ EventMachine.run do
612
+ trap(:INT) { EventMachine.stop }
613
+
614
+ PryRemoteEm::Server.run name: 'Demo Server', heartbeat_interval: 1, details: { hand_check: false }
615
+ end
616
+ ```
617
+
618
+ Then, in shell:
619
+
620
+ ```shell
621
+ $ pry-remote-em -P --sn -d hand_check
622
+ [pry-remote-em] client connected to pryem://127.0.0.1:6462/
623
+ [pry-remote-em] remote is PryRemoteEm 1.0.0 pryem
624
+ --------------------------------------
625
+ | | name | hand_check |
626
+ --------------------------------------
627
+ | 1 | Demo Server | true |
628
+ | 2 | Demo Server | true |
629
+ | 3 | Demo Server | false |
630
+ | 4 | Demo Server | false |
631
+ | 5 | Demo Server | false |
632
+ --------------------------------------
633
+ (q) to quit; (r) to refresh; (c) to connect without proxy
634
+ proxy to: 3
635
+ [1] Demo Server (sandbox)> HealthChecker.all_ok?
636
+ => true
637
+ [2] Demo Server (sandbox)> server[:details][:hand_check] = true
638
+ => true
639
+ [3] Demo Server (sandbox)> exit
640
+ [pry-remote-em] session terminated
641
+ $
642
+ $ sleep 1
643
+ $ pry-remote-em -P --sn -d hand_check
644
+ [pry-remote-em] client connected to pryem://127.0.0.1:6462/
645
+ [pry-remote-em] remote is PryRemoteEm 1.0.0 pryem
646
+ --------------------------------------
647
+ | | name | hand_check |
648
+ --------------------------------------
649
+ | 1 | Demo Server | true |
650
+ | 2 | Demo Server | true |
651
+ | 3 | Demo Server | true |
652
+ | 4 | Demo Server | false |
653
+ | 5 | Demo Server | false |
654
+ --------------------------------------
655
+ (q) to quit; (r) to refresh; (c) to connect without proxy
656
+ proxy to:
657
+ ```
658
+
387
659
  ## Messaging
388
660
  It is possible for each pry-remote-em service to host multiple
389
661
  simultaneous connections. You can send messages to other connections
390
- with the '!' and '!!' prefix.
662
+ with the '^' and '^^' prefix.
391
663
 
392
- The '!' prefix will send the message to connections on the same object.
393
- the '!!' prefix will send the message to all connections in the current
664
+ The '^' prefix will send the message to connections on the same object.
665
+ the '^^' prefix will send the message to all connections in the current
394
666
  process.
395
667
 
396
668
  Message will not be displayed by the clients until the presses enter.
@@ -403,8 +675,8 @@ Available events are:
403
675
  - auth_ok - called each time authentication succeeds
404
676
 
405
677
  ```ruby
406
- log = ::Logger.new('/var/log/auth.pry.log')
407
- obj.new.remote_pry_em('0.0.0.0', :auto, :tls => true, :auth => auth_hash) do |pry|
678
+ log = ::Logger.new('/var/log/auth.pry.log')
679
+ obj.new.remote_pry_em('0.0.0.0', :auto, tls: true, auth: auth_hash) do |pry|
408
680
  pry.auth_attempt do |user, ip|
409
681
  log.info("got an authentication attempt for #{user} from #{ip}")
410
682
  end
@@ -418,8 +690,8 @@ end
418
690
  ```
419
691
 
420
692
  ## Shell Commands
421
- If the pry-remote-em service is started with the ``:allow_shell_cmds =>
422
- true`` option set it will spawn sub processes for any command prefixed
693
+ Unless the pry-remote-em service is started with the ``allow_shell_cmds:
694
+ false`` option set it will spawn sub processes for any command prefixed
423
695
  with a '.'.
424
696
 
425
697
  ```
@@ -431,7 +703,7 @@ Interactive commands like ``vim`` will probably not behave
431
703
  appropriately.
432
704
 
433
705
 
434
- If the server was not started with the ``allow_shell_cmds`` option then
706
+ If the server was started with the ``allow_shell_cmds: false`` option then
435
707
  all shell commands will be met with a rejection notice.
436
708
 
437
709
  ```
@@ -439,8 +711,7 @@ all shell commands will be met with a rejection notice.
439
711
  shell commands are not allowed by this server
440
712
  ```
441
713
 
442
- The server will also log whenever a user attempts to execute a shell
443
- command.
714
+ The server will also log whenever a user attempts to execute a shell command.
444
715
 
445
716
  ```
446
717
  W, [2012-02-11T19:21:27.663941 #36471] WARN -- : executing shell command 'ls -al' for (127.0.0.1:63878)
@@ -450,18 +721,31 @@ W, [2012-02-11T19:21:27.663941 #36471] WARN -- : executing shell command 'ls -a
450
721
  E, [2012-02-11T19:23:40.770380 #36471] ERROR -- : refused to execute shell command 'ls' for caleb (127.0.0.1:63891)
451
722
  ```
452
723
 
453
- # Missing Features
724
+ # Environment variables
725
+
726
+ * PRYEMNAME - pry server name to show in broker's list, default - target object's inspect
727
+ * PRYEMURL - pry server URL to show in broker's list, default - pryem://#{server_host}:#{server_port}/
728
+ * PRYEMHOST - host to bind pry server, default - 127.0.0.1
729
+ * PRYEMPORT - port to bind pry server, default - 6463
730
+ * PRYEMBROKER - host to bind pry broker, default - 127.0.0.1
731
+ * PRYEMBROKERPORT - port to bind pry broker, default - 6462
732
+ * PRYEMREMOTEBROKER - start server without starting broker, default - broker starting with server
733
+ * PRYEMNOPAGER - disable paging on long output, default - pager enabled
734
+ * PRYEMNEGOTIMEOUT - connection negotiation timeout in seconds, default - 15
735
+ * PRYEMHBSEND - server to broker heartbeat interval in seconds, default - 15
736
+ * PRYEMHBCHECK - heartbeat check on broker interval in seconds, default - 20
737
+ * PRYEMBROKERTIMEOUT - reconnect to broker timeout in seconds, default - 3
738
+ * PRYEMSANDBOXERRORS - number of errors to store in sandbox, default - 100
454
739
 
455
- - HTTP Transport [ticket](https://github.com/simulacre/pry-remote-em/issues/12)
456
- - Ssh key based authentication
740
+ # Missing Features
457
741
 
742
+ - HTTP Transport ([ticket](https://github.com/gruis/pry-remote-em/issues/12))
743
+ - SSH key based authentication
744
+ - Looking for connected users and their history
458
745
 
459
746
  # Issues
460
747
 
461
- Please post any bug reports or feature requests on [Github](https://github.com/simulacre/pry-remote-em/issues)
462
-
463
-
464
-
748
+ Please post any bug reports or feature requests on [Github](https://github.com/gruis/pry-remote-em/issues)
465
749
 
466
750
  # Copyright
467
751
 
@@ -469,7 +753,7 @@ Copyright (c) 2012 Caleb Crane
469
753
 
470
754
  Permission is hereby granted, free of charge, to any person obtaining a
471
755
  copy of this software and associated documentation files (the "Software"),
472
- to deal in the Software without restriction, including without limitation
756
+ to deal in the Software without restriction, including without limitation
473
757
  the rights to use, copy, modify, merge, publish, distribute, sublicense,
474
758
  and/or sell copies of the Software, and to permit persons to whom the
475
759
  Software is furnished to do so, subject to the following conditions: