Skip to content

Commit

Permalink
Merge pull request #38 from glennsarti/use-random-port
Browse files Browse the repository at this point in the history
(GH-36) Use automatic port assignment as default
  • Loading branch information
James Pogran authored Jun 22, 2018
2 parents d3f0584 + 2d1b70f commit 597bcf2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ Note the language server will stop after 10 seconds if no client connection is m

```
Usage: puppet-languageserver.rb [options]
-p, --port=PORT TCP Port to listen on. Default is 8081
-i, --ip=ADDRESS IP Address to listen on (0.0.0.0 for all interfaces). Default is 127.0.0.1
-p, --port=PORT TCP Port to listen on. Default is random port
-i, --ip=ADDRESS IP Address to listen on (0.0.0.0 for all interfaces). Default is localhost
-c, --no-stop Do not stop the language server once a client disconnects. Default is to stop
-t, --timeout=TIMEOUT Stop the language server if a client does not connection within TIMEOUT seconds. A value of zero will not timeout. Default is 10 seconds
-d, --no-preload ** DEPRECATED ** Do not preload Puppet information when the language server starts. Default is to preload
Expand Down Expand Up @@ -185,8 +185,8 @@ Note the debug server will stop after 10 seconds if no client connection is made

```
Usage: puppet-debugserver.rb [options]
-p, --port=PORT TCP Port to listen on. Default is 8082
-i, --ip=ADDRESS IP Address to listen on (0.0.0.0 for all interfaces). Default is 127.0.0.1
-p, --port=PORT TCP Port to listen on. Default is random port}
-i, --ip=ADDRESS IP Address to listen on (0.0.0.0 for all interfaces). Default is localhost
-t, --timeout=TIMEOUT Stop the Debug Server if a client does not connection within TIMEOUT seconds. A value of zero will not timeout. Default is 10 seconds
--debug=DEBUG Output debug information. Either specify a filename or 'STDOUT'. Default is no debug output
-h, --help Prints this help
Expand Down
6 changes: 3 additions & 3 deletions lib/puppet-debugserver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class CommandLineParser
def self.parse(options)
# Set defaults here
args = {
port: 8082,
ipaddress: '127.0.0.1',
port: nil,
ipaddress: 'localhost',
stop_on_client_exit: true,
connection_timeout: 10,
debug: nil
Expand All @@ -31,7 +31,7 @@ def self.parse(options)
opt_parser = OptionParser.new do |opts|
opts.banner = 'Usage: puppet-debugserver.rb [options]'

opts.on('-pPORT', '--port=PORT', "TCP Port to listen on. Default is #{args[:port]}") do |port|
opts.on('-pPORT', '--port=PORT', "TCP Port to listen on. Default is random port}") do |port|
args[:port] = port.to_i
end

Expand Down
10 changes: 5 additions & 5 deletions lib/puppet-editor-services/simple_tcp_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -251,13 +251,13 @@ def io_review
# IO - listening sockets (services)

# @api public
def add_service(hostname = '127.0.0.1', port = 8081, parameters = {})
parameters[:port] = port
def add_service(hostname = 'localhost', port = nil, parameters = {})
hostname = 'localhost' if hostname.nil? || hostname.empty?
service = TCPServer.new(hostname, port)
parameters[:hostname] = hostname
parameters.update port if port.is_a?(Hash)
service = TCPServer.new(parameters[:hostname], parameters[:port])
parameters[:port] = service.local_address.ip_port
self.class.s_locker.synchronize { self.class.services[service] = parameters }
callback(self, :log, "Started listening on #{hostname}:#{port}.")
callback(self, :log, "Started listening on #{hostname}:#{parameters[:port]}.")
true
end

Expand Down
6 changes: 3 additions & 3 deletions lib/puppet-languageserver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ def self.parse(options)
# Set defaults here
args = {
stdio: false,
port: 8081,
ipaddress: '127.0.0.1',
port: nil,
ipaddress: 'localhost',
stop_on_client_exit: true,
connection_timeout: 10,
preload_puppet: true,
Expand All @@ -55,7 +55,7 @@ def self.parse(options)
opt_parser = OptionParser.new do |opts|
opts.banner = 'Usage: puppet-languageserver.rb [options]'

opts.on('-pPORT', '--port=PORT', "TCP Port to listen on. Default is #{args[:port]}") do |port|
opts.on('-pPORT', '--port=PORT', "TCP Port to listen on. Default is random port") do |port|
args[:port] = port.to_i
end

Expand Down

0 comments on commit 597bcf2

Please sign in to comment.