Skip to content

Commit

Permalink
[#988] Possibility to append java memory options to dependencies + ev…
Browse files Browse the repository at this point in the history
…olutions command + doc for evolutions
  • Loading branch information
xael-fry authored and Notalifeform committed Oct 4, 2013
1 parent f07a1b5 commit a27f488
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 26 deletions.
13 changes: 11 additions & 2 deletions documentation/commands/cmd-dependencies.txt
Expand Up @@ -8,7 +8,7 @@
~
~ Synopsis:
~ ~~~~~~~~~
~ play dependencies [app_path] [--verbose] [--debug] [--sync] [--%fwk_id] [--forProd] [--clearcache]
~ play dependencies [app_path] [--verbose] [--debug] [--sync] [--%fwk_id] [--forProd] [--clearcache] [--jpda]
~
~ Description:
~ ~~~~~~~~~~~~
Expand All @@ -19,6 +19,15 @@
~ Use the --sync option to keep both lib/ and modules/ directory synchronized
~ with the dependencies management system.
~
~ Some options specified after the application path are passed to the JVM : java memory( example. -Xms64m -Xmx256m).
~ If JVM memory options (starting with -Xm') are not specified in command line arguments, then any
~ arguments in the conf/application.conf file's jvm.memory property are passed to the JVM.
~ All the shell environment variables are passed to the JVM.
~
~ If the option [--jpda] is present, a JPDA session is automatically opened on the port specified by the
~ conf/application.conf file's jpda.port property (defaulting to 8000). If the JPDA port is already in use,
~ another available port is automatically chosen.
~
~ Options:
~ ~~~~~~~~
~ --verbose:
Expand All @@ -33,7 +42,7 @@
~
~ --sync:
~ Keep lib/ and modules/ directory synced.
~ Delete unknow dependencies.
~ Delete unknown dependencies.
~
~ --forceCopy:
~ Never create files pointing to the original folder, always copy the folder
Expand Down
40 changes: 40 additions & 0 deletions documentation/commands/cmd-evolutions.txt
@@ -0,0 +1,40 @@
~ Name:
~ ~~~~~
~ evolutions -- Run the evolution check
~ evolutions:apply -- Automatically apply pending evolutions
~ evolutions:markApplied -- Mark pending evolutions as manually applied
~ evolutions:resolve -- Resolve partially applied evolution
~
~ Alias:
~ ~~~~~
~ ev
~
~ Synopsis:
~ ~~~~~~~~~
~ play evolutions [app_path] [--jpda]
~ play evolutions:apply [app_path] [--jpda]
~ play evolutions:markApplied [app_path] [--jpda]
~ play evolutions:resolve [app_path] [--jpda]
~
~ Description:
~ ~~~~~~~~~~~~
~ Track and organize your database schema evolutions evolutions
~ Play tracks your database evolutions using several "evolutions script".
~ These scripts are written in plain old SQL and should be located in the db/evolutions directory of your application.
~
~ All options specified after the application path are passed to the JVM (example. -Xms64m -Xmx256m).
~ If JVM memory options (starting with -Xm') are not specified in command line arguments, then any
~ arguments in the conf/application.conf file's jvm.memory property are passed to the JVM.
~ All the shell environment variables are passed to the JVM.
~
~ If the option [--jpda] is present, a JPDA session is automatically opened on the port specified by the
~ conf/application.conf file's jpda.port property (defaulting to 8000). If the JPDA port is already in use,
~ another available port is automatically chosen.
~
~ Options:
~ ~~~~~~~~
~
~ --jpda:
~ Listen for JPDA connection. The process will be suspended until
~ a client is plugged to the JPDA port.
~
21 changes: 19 additions & 2 deletions framework/pym/play/application.py
Expand Up @@ -226,6 +226,23 @@ def check_jpda(self):
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 = []
memory_in_args=False
for arg in java_args:
if arg.startswith('-Xm'):
memory_in_args=True
args_memory.append(arg)

if not memory_in_args:
memory = self.readConf('jvm.memory')
if memory:
args_memory = args_memory + memory.split(' ')
elif 'JAVA_OPTS' in os.environ:
args_memory = args_memory + os.environ['JAVA_OPTS'].split(' ')

return args_memory

def java_cmd(self, java_args, cp_args=None, className='play.server.Server', args = None):
if args is None:
args = ['']
Expand All @@ -246,8 +263,8 @@ def java_cmd(self, java_args, cp_args=None, className='play.server.Server', args

if application_mode == 'prod':
java_args.append('-server')
# JDK 7 compat
java_args.append('-XX:-UseSplitVerifier')
# JDK 7 compat
java_args.append('-XX:-UseSplitVerifier')
java_policy = self.readConf('java.policy')
if java_policy != '':
policyFile = os.path.join(self.path, 'conf', java_policy)
Expand Down
29 changes: 19 additions & 10 deletions framework/pym/play/commands/deps.py
Expand Up @@ -13,9 +13,6 @@
}

def execute(**kargs):
args = kargs.get("args")
play_env = kargs.get("env")

command = kargs.get("command")
app = kargs.get("app")
args = kargs.get("args")
Expand All @@ -33,26 +30,38 @@ def execute(**kargs):
trim = "true"

classpath = app.getClasspath()
args_memory = app.java_args_memory(args)
app.jpda_port = app.readConf('jpda.port')

add_options = ['-Dapplication.path=%s' % (app.path), '-Dframework.path=%s' % (play_env['basedir']), '-Dplay.id=%s' % play_env['id'], '-Dplay.version=%s' % play_env['version'], '-Dplay.forcedeps=%s' % (force), '-Dplay.trimdeps=%s' % (trim)]
if args.count('--verbose'):
args.remove('--verbose')
add_options.append('-Dverbose')
if args.count('--sync'):
args.remove('--sync')
add_options.append('-Dsync')
if args.count('--debug'):
args.remove('--debug')
add_options.append('-Ddebug')
if args.count('--clearcache'):
args.remove('--clearcache')
add_options.append('-Dclearcache')
if args.count('--jpda'):
args.remove('--jpda')
print "~ Waiting for JPDA client to continue"
add_options.extend(['-Xdebug', '-Xrunjdwp:transport=dt_socket,address=8888,server=y,suspend=y'])
add_options.append('-Xdebug')
add_options.append('-Xrunjdwp:transport=dt_socket,address=%s,server=y,suspend=y' % app.jpda_port)
for arg in args:
if arg.startswith("-D"):
add_options.append(arg)
elif not arg.startswith('-Xm'):
print "~ WARNING: " + arg + " argument will be skipped"

java_cmd = [app.java_path()] + add_options + ['-classpath', app.fw_cp_args(), 'play.deps.DependenciesManager']

return_code = subprocess.call(java_cmd, env=os.environ)
if 0 != return_code:
sys.exit(return_code);

java_cmd = [app.java_path()] + add_options + args_memory + ['-classpath', app.fw_cp_args(), 'play.deps.DependenciesManager']
try:
return_code = subprocess.call(java_cmd, env=os.environ)
if 0 != return_code:
sys.exit(return_code);
except OSError:
print "Could not execute the java executable, please make sure the JAVA_HOME environment variable is set properly (the java executable should reside at JAVA_HOME/bin/java). "
sys.exit(-1)
29 changes: 17 additions & 12 deletions framework/pym/play/commands/evolutions.py
Expand Up @@ -16,16 +16,11 @@
}

def execute(**kargs):

args = kargs.get("args")
play_env = kargs.get("env")

command = kargs.get("command")
app = kargs.get("app")
args = kargs.get("args")
play_env = kargs.get("env")


if command.find(':resolve') > 0:
args.append('-Dmode=resolve')

Expand All @@ -36,16 +31,26 @@ def execute(**kargs):
args.append('-Dmode=markApplied')

classpath = app.getClasspath()
args_memory = app.java_args_memory(args)
app.jpda_port = app.readConf('jpda.port')

add_options = ['-Dapplication.path=%s' % (app.path), '-Dframework.path=%s' % (play_env['basedir']), '-Dplay.id=%s' % play_env['id'], '-Dplay.version=%s' % play_env['version']]
if args.count('--jpda'):
print "~ Waiting for JPDA client to continue"
add_options.extend(['-Xdebug', '-Xrunjdwp:transport=dt_socket,address=8888,server=y,suspend=y'])
args.remove('--jpda')
add_options.append('-Xdebug')
add_options.append('-Xrunjdwp:transport=dt_socket,address=%s,server=y,suspend=y' % app.jpda_port)
add_options.extend(args)

java_cmd = [app.java_path()] + add_options + ['-classpath', app.cp_args(), 'play.db.Evolutions']

return_code = subprocess.call(java_cmd, env=os.environ)
if 0 != return_code:
sys.exit(return_code);
# Remove duplicate memory arg
for arg in args_memory:
if arg in add_options:
add_options.remove(arg)

java_cmd = [app.java_path()] + add_options + args_memory + ['-classpath', app.cp_args(), 'play.db.Evolutions']
try:
return_code = subprocess.call(java_cmd, env=os.environ)
if 0 != return_code:
sys.exit(return_code);
except OSError:
print "Could not execute the java executable, please make sure the JAVA_HOME environment variable is set properly (the java executable should reside at JAVA_HOME/bin/java). "
sys.exit(-1)

0 comments on commit a27f488

Please sign in to comment.