Added an option to game/runner.py for launching the components under the cProfile python profiler.
This commit is contained in:
parent
cdab5a240b
commit
fdceb93dcb
1 changed files with 25 additions and 2 deletions
|
|
@ -211,6 +211,13 @@ def main():
|
||||||
parser.add_option('-d', '--iportal', action='store_true',
|
parser.add_option('-d', '--iportal', action='store_true',
|
||||||
dest='iportal', default=False,
|
dest='iportal', default=False,
|
||||||
help=_('output portal log to stdout. Does not make portal a daemon.'))
|
help=_('output portal log to stdout. Does not make portal a daemon.'))
|
||||||
|
parser.add_option('-S', '--profile-server', action='store_true',
|
||||||
|
dest='sprof', default=False,
|
||||||
|
help='run server under cProfile')
|
||||||
|
parser.add_option('-P', '--profile-portal', action='store_true',
|
||||||
|
dest='pprof', default=False,
|
||||||
|
help='run portal under cProfile')
|
||||||
|
|
||||||
options, args = parser.parse_args()
|
options, args = parser.parse_args()
|
||||||
|
|
||||||
if not args or args[0] != 'start':
|
if not args or args[0] != 'start':
|
||||||
|
|
@ -228,6 +235,16 @@ def main():
|
||||||
'--logfile=%s' % PORTAL_LOGFILE,
|
'--logfile=%s' % PORTAL_LOGFILE,
|
||||||
'--pidfile=%s' % PORTAL_PIDFILE,
|
'--pidfile=%s' % PORTAL_PIDFILE,
|
||||||
'--python=%s' % PORTAL_PY_FILE]
|
'--python=%s' % PORTAL_PY_FILE]
|
||||||
|
|
||||||
|
# Profiling settings (read file from python shell e.g with
|
||||||
|
# p = pstats.Stats('server.prof')
|
||||||
|
sprof_argv = ['--savestats',
|
||||||
|
'--profiler=cprofile',
|
||||||
|
'--profile=server.prof']
|
||||||
|
pprof_argv = ['--savestats',
|
||||||
|
'--profiler=cprofile',
|
||||||
|
'--profile=portal.prof']
|
||||||
|
|
||||||
# Server
|
# Server
|
||||||
|
|
||||||
pid = get_pid(SERVER_PIDFILE)
|
pid = get_pid(SERVER_PIDFILE)
|
||||||
|
|
@ -242,6 +259,9 @@ def main():
|
||||||
# don't log to server logfile
|
# don't log to server logfile
|
||||||
del server_argv[2]
|
del server_argv[2]
|
||||||
print _("\nStarting Evennia Server (output to stdout).")
|
print _("\nStarting Evennia Server (output to stdout).")
|
||||||
|
elif options.sprof:
|
||||||
|
server_argv.extend(sprof_argv)
|
||||||
|
print "\nRunning Evennia Server under cProfile."
|
||||||
else:
|
else:
|
||||||
print _("\nStarting Evennia Server (output to server logfile).")
|
print _("\nStarting Evennia Server (output to server logfile).")
|
||||||
cycle_logfile(SERVER_LOGFILE)
|
cycle_logfile(SERVER_LOGFILE)
|
||||||
|
|
@ -261,6 +281,9 @@ def main():
|
||||||
PORTAL_INTERACTIVE = True
|
PORTAL_INTERACTIVE = True
|
||||||
set_restart_mode(PORTAL_RESTART, True)
|
set_restart_mode(PORTAL_RESTART, True)
|
||||||
print _("\nStarting Evennia Portal in non-Daemon mode (output to stdout).")
|
print _("\nStarting Evennia Portal in non-Daemon mode (output to stdout).")
|
||||||
|
elif options.pprof:
|
||||||
|
server_argv.extend(pprof_argv)
|
||||||
|
print "\nRunning Evennia Portal under cProfile."
|
||||||
else:
|
else:
|
||||||
set_restart_mode(PORTAL_RESTART, False)
|
set_restart_mode(PORTAL_RESTART, False)
|
||||||
print _("\nStarting Evennia Portal in Daemon mode (output to portal logfile).")
|
print _("\nStarting Evennia Portal in Daemon mode (output to portal logfile).")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue