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 2781512 commit 4e6ff93
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
Expand Up @@ -4,7 +4,7 @@
~ ~
~ Synopsis: ~ 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: ~ Description:
~ ~~~~~~~~~~~~ ~ ~~~~~~~~~~~~
Expand Down Expand Up @@ -37,3 +37,11 @@
~ --silent: ~ --silent:
~ Suppress output of the Play ASCII art logo and framework version information. ~ 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
Expand Up @@ -4,7 +4,7 @@
~ ~
~ Synopsis: ~ 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: ~ Description:
~ ~~~~~~~~~~~~ ~ ~~~~~~~~~~~~
Expand All @@ -25,9 +25,23 @@
~ ~
~ Options: ~ Options:
~ ~~~~~~~~~ ~ ~~~~~~~~~
~ -f:
~ Disable the JPDA port checking and force the jpda.port value.
~
~ --%fwk_id: ~ --%fwk_id:
~ Use this ID to run the application (override the default framework ID) ~ Use this ID to run the application (override the default framework ID)
~ ~
~ --deps: ~ --deps:
~ Resolve and install dependencies before running the command. ~ 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
Expand Up @@ -33,7 +33,12 @@ def __init__(self, application_path, env, ignoreMissingModules = False):
else: else:
self.conf = None self.conf = None
self.play_env = env 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 self.ignoreMissingModules = ignoreMissingModules


# ~~~~~~~~~~~~~~~~~~~~~~ Configuration File # ~~~~~~~~~~~~~~~~~~~~~~ Configuration File
Expand Down Expand Up @@ -223,8 +228,12 @@ def check_jpda(self):
s.bind(('', int(self.jpda_port))) s.bind(('', int(self.jpda_port)))
s.close() s.close()
except socket.error, e: except socket.error, e:
print 'JPDA port %s is already used. Will try to use any free port for debugging' % self.jpda_port if self.play_env["disable_random_jpda"]:
self.jpda_port = 0 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): def java_args_memory(self, java_args):
args_memory = [] args_memory = []
Expand Down Expand Up @@ -259,7 +268,8 @@ def java_cmd(self, java_args, cp_args=None, className='play.server.Server', args
if cp_args is None: if cp_args is None:
cp_args = self.cp_args() 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() application_mode = self.readConf('application.mode').lower()


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


if self.readConf('application.mode').lower() == 'dev': 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('-Xdebug')
java_args.append('-Xrunjdwp:transport=dt_socket,address=%s,server=y,suspend=n' % self.jpda_port) java_args.append('-Xrunjdwp:transport=dt_socket,address=%s,server=y,suspend=n' % self.jpda_port)
java_args.append('-Dplay.debug=yes') java_args.append('-Dplay.debug=yes')
Expand Down Expand Up @@ -320,6 +330,8 @@ class PlayConfParser:
def __init__(self, confFolder, env): def __init__(self, confFolder, env):
self.id = env["id"] self.id = env["id"]
self.entries = self.readFile(confFolder, "application.conf") 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'): if env.has_key('http.port'):
self.entries['http.port'] = env['http.port'] self.entries['http.port'] = env['http.port']


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


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


# ~~~~~~~~~~~~~~~~~ Checking for disable_check_jpda # ~~~~~~~~~~~~~~~~~ Checking for disable_random_jpda
disable_check_jpda = False disable_random_jpda = False
if remaining_args.count('-f') == 1: if remaining_args.count('-f') == 1:
disable_check_jpda = True disable_random_jpda = True
remaining_args.remove('-f') 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) play_app = PlayApplication(application_path, play_env, ignoreMissing)


Expand Down

0 comments on commit 4e6ff93

Please sign in to comment.