浏览代码

[minor] add profiling in development server

version-14
Pratik Vyas 11 年前
父节点
当前提交
f31a5510e1
共有 2 个文件被更改,包括 9 次插入3 次删除
  1. +6
    -1
      webnotes/app.py
  2. +3
    -2
      wnf.py

+ 6
- 1
webnotes/app.py 查看文件

@@ -9,6 +9,7 @@ from werkzeug.wrappers import Request, Response
from werkzeug.local import LocalManager
from webnotes.middlewares import StaticDataMiddleware
from werkzeug.exceptions import HTTPException
from werkzeug.contrib.profiler import ProfilerMiddleware
from webnotes import get_config

import mimetypes
@@ -58,7 +59,11 @@ application = StaticDataMiddleware(application, {
'/': 'public',
})

def serve(port=8000):

def serve(port=8000, profile=False):
global application
from werkzeug.serving import run_simple
if profile:
application = ProfilerMiddleware(application)
run_simple('0.0.0.0', int(port), application, use_reloader=True,
use_debugger=True, use_evalex=True)

+ 3
- 2
wnf.py 查看文件

@@ -137,6 +137,7 @@ def setup_utilities(parser):
help="Set administrator password")
parser.add_argument("--mysql", action="store_true", help="get mysql shell for a site")
parser.add_argument("--serve", action="store_true", help="Run development server")
parser.add_argument("--profile", action="store_true", help="enable profiling in development server")
parser.add_argument("--smtp", action="store_true", help="Run smtp debug server",
dest="smtp_debug_server")
parser.add_argument("--python", action="store_true", help="get python shell for a site")
@@ -593,9 +594,9 @@ def smtp_debug_server():
os.execv(python, [python, '-m', "smtpd", "-n", "-c", "DebuggingServer", "localhost:25"])
@cmd
def serve(port=8000):
def serve(port=8000, profile=False):
import webnotes.app
webnotes.app.serve(port=port)
webnotes.app.serve(port=port, profile=profile)

def replace_code(start, txt1, txt2, extn, search=None, force=False):
"""replace all txt1 by txt2 in files with extension (extn)"""


正在加载...
取消
保存