Skip to content

Commit

Permalink
[#1744] Added parameter parsing for the command line option --jpda.po…
Browse files Browse the repository at this point in the history
…rt=<port number>

Use the framework id when parsing the jpda.port so that we can specify a separate fixed port to use for debugging per mode
Fixed bug where adding the option '-f' would actually always randomise the jpda_port
Add documentation for the following command line options: http.port, https.port, jpda.port and pid_file
  • Loading branch information
Kai Inkinen authored and Notalifeform committed Nov 9, 2013
1 parent 900ea9b commit 4513e59
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 12 deletions.
10 changes: 9 additions & 1 deletion documentation/commands/cmd-run.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
~
~ Synopsis:
~ ~~~~~~~~~
~ play run [app_path] [--deps] [--%fwk_id] [-f] [--java_options]
~ play run [app_path] [-f] [--deps] [--%fwk_id] [--http[s].port=<value>] [--jpda.port=<value>] [--java_options]
~
~ Description:
~ ~~~~~~~~~~~~
Expand Down Expand Up @@ -37,3 +37,11 @@
~ --silent:
~ Suppress output of the Play ASCII art logo and framework version information.
~
~ --http.port=<value>:
~ Override the http.port and %fwk_id.http.port variables in application.conf, and listen to the specified http port
~
~ --https.port=<value>:
~ Override the https.port and %fwk_id.https.port variables in application.conf, and listen to the specified https port
~
~ --jpda.port=<value>:
~ Override the jpda.port and %fwk_id.jpda.port variables in application.conf. Use the specified port (<value>) as the remote debugging port for the application. Can be combined with the option -f
18 changes: 16 additions & 2 deletions documentation/commands/cmd-start.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
~
~ Synopsis:
~ ~~~~~~~~~
~ play start [app_path] [--deps] [--%fwk_id] [--java_options]
~ play start [app_path] ] [-f] [--deps] [--%fwk_id] [--http[s].port=<value>] [--jpda.port=<value>] [--pid_file=<file>] [--java_options]
~
~ Description:
~ ~~~~~~~~~~~~
Expand All @@ -25,9 +25,23 @@
~
~ Options:
~ ~~~~~~~~~
~ -f:
~ Disable the JPDA port checking and force the jpda.port value.
~
~ --%fwk_id:
~ Use this ID to run the application (override the default framework ID)
~
~ --deps:
~ Resolve and install dependencies before running the command.
~
~
~ --pid_file=<file>:
~ Specify where to write the process id (pid) of the background server process.
~
~ --http.port=<value>:
~ Override the http.port and %fwk_id.http.port variables in application.conf, and listen to the specified http port
~
~ --https.port=<value>:
~ Override the https.port and %fwk_id.https.port variables in application.conf, and listen to the specified https port
~
~ --jpda.port=<value>:
~ Override the jpda.port and %fwk_id.jpda.port variables in application.conf. Use the specified port (<value>) as the remote debugging port for the application. Can be combined with the option -f
22 changes: 17 additions & 5 deletions framework/pym/play/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ def __init__(self, application_path, env, ignoreMissingModules = False):
else:
self.conf = None
self.play_env = env
self.jpda_port = self.readConf('jpda.port')

if env.has_key('jpda.port'):
self.jpda_port = env['jpda.port']
else:
self.jpda_port = self.readConf('jpda.port')

self.ignoreMissingModules = ignoreMissingModules

# ~~~~~~~~~~~~~~~~~~~~~~ Configuration File
Expand Down Expand Up @@ -223,8 +228,12 @@ def check_jpda(self):
s.bind(('', int(self.jpda_port)))
s.close()
except socket.error, e:
print 'JPDA port %s is already used. Will try to use any free port for debugging' % self.jpda_port
self.jpda_port = 0
if self.play_env["disable_random_jpda"]:
print 'JPDA port %s is already used, and command line option "-f" was specified. Cannot start server\n' % self.jpda_port
sys.exit(-1)
else:
print 'JPDA port %s is already used. Will try to use any free port for debugging' % self.jpda_port
self.jpda_port = 0

def java_args_memory(self, java_args):
args_memory = []
Expand Down Expand Up @@ -257,7 +266,8 @@ def java_cmd(self, java_args, cp_args=None, className='play.server.Server', args
if cp_args is None:
cp_args = self.cp_args()

self.jpda_port = self.readConf('jpda.port')
if self.play_env.has_key('jpda.port'):
self.jpda_port = self.play_env['jpda.port']

application_mode = self.readConf('application.mode').lower()

Expand All @@ -281,7 +291,7 @@ def java_cmd(self, java_args, cp_args=None, className='play.server.Server', args
java_args.append('-Dfile.encoding=utf-8')

if self.readConf('application.mode').lower() == 'dev':
if not self.play_env["disable_check_jpda"]: self.check_jpda()
self.check_jpda()
java_args.append('-Xdebug')
java_args.append('-Xrunjdwp:transport=dt_socket,address=%s,server=y,suspend=n' % self.jpda_port)
java_args.append('-Dplay.debug=yes')
Expand Down Expand Up @@ -318,6 +328,8 @@ class PlayConfParser:
def __init__(self, confFolder, env):
self.id = env["id"]
self.entries = self.readFile(confFolder, "application.conf")
if env.has_key('jpda.port'):
self.entries['jpda.port'] = env['jpda.port']
if env.has_key('http.port'):
self.entries['http.port'] = env['http.port']

Expand Down
9 changes: 5 additions & 4 deletions play
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ try:
# ~~~~~~~~~~~~~~~~~ Override port
get_opt(remaining_args, "http.port", play_env)
get_opt(remaining_args, "https.port", play_env)
get_opt(remaining_args, "jpda.port", play_env)

# ~~~~~~~~~~~~~~~~~ Override id
for a in remaining_args:
Expand All @@ -119,12 +120,12 @@ try:
print "~ framework ID is %s" % play_env["id"]
print "~"

# ~~~~~~~~~~~~~~~~~ Checking for disable_check_jpda
disable_check_jpda = False
# ~~~~~~~~~~~~~~~~~ Checking for disable_random_jpda
disable_random_jpda = False
if remaining_args.count('-f') == 1:
disable_check_jpda = True
disable_random_jpda = True
remaining_args.remove('-f')
play_env["disable_check_jpda"] = disable_check_jpda
play_env["disable_random_jpda"] = disable_random_jpda

play_app = PlayApplication(application_path, play_env, ignoreMissing)

Expand Down

0 comments on commit 4513e59

Please sign in to comment.