From 434c892ac004cffbf724214132540a282d02ccf2 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Thu, 16 Jul 2020 17:05:08 +0530 Subject: [PATCH] feat: Bench command to open ngrok tunnel (#11024) Co-authored-by: Suraj Shetty <13928957+surajshetty3416@users.noreply.github.com> --- frappe/commands/site.py | 26 +++++++++++++++++++++++++- requirements.txt | 5 +++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/frappe/commands/site.py b/frappe/commands/site.py index ec80ee019d..26eb455338 100755 --- a/frappe/commands/site.py +++ b/frappe/commands/site.py @@ -631,6 +631,29 @@ def stop_recording(context): if not context.sites: raise SiteNotSpecifiedError +@click.command('ngrok') +@pass_context +def start_ngrok(context): + from pyngrok import ngrok + + site = get_site(context) + frappe.init(site=site) + + port = frappe.conf.http_port or frappe.conf.webserver_port + public_url = ngrok.connect(port=port, options={ + 'host_header': site + }) + print(f'Public URL: {public_url}') + print('Inspect logs at http://localhost:4040') + + ngrok_process = ngrok.get_ngrok_process() + try: + # Block until CTRL-C or some other terminating event + ngrok_process.proc.wait() + except KeyboardInterrupt: + print("Shutting down server...") + frappe.destroy() + ngrok.kill() commands = [ add_system_manager, @@ -656,5 +679,6 @@ commands = [ browse, start_recording, stop_recording, - add_to_hosts + add_to_hosts, + start_ngrok ] diff --git a/requirements.txt b/requirements.txt index 0d01886f05..e0ca1a6fad 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,8 +13,8 @@ dropbox==9.1.0 email-reply-parser==0.5.9 Faker==2.0.4 future==0.18.2 -GitPython==2.1.15 gitdb2==2.0.6;python_version<'3.4' +GitPython==2.1.15 google-api-python-client==1.9.3 google-auth-httplib2==0.0.3 google-auth-oauthlib==0.4.1 @@ -40,6 +40,7 @@ psycopg2-binary==2.8.4 pyasn1==0.4.8 PyJWT==1.7.1 PyMySQL==0.9.3 +pyngrok==4.1.6 pyOpenSSL==19.1.0 pyotp==2.3.0 PyPDF2==1.26.0 @@ -64,6 +65,6 @@ unittest-xml-reporting==2.5.2 urllib3==1.25.8 watchdog==0.8.0 Werkzeug==0.16.1 +Whoosh==2.7.4 xlrd==1.2.0 zxcvbn-python==4.4.24 -Whoosh==2.7.4