From 31b908226a7cbab946787271ff35ffae1a43516c Mon Sep 17 00:00:00 2001 From: Sergey Golitsynskiy Date: Wed, 28 Oct 2020 14:08:25 -0400 Subject: [PATCH] Set uwsgi's honor-stdin when in debug mode --- doc/source/admin/galaxy_options.rst | 5 +++++ lib/galaxy/config/sample/galaxy.yml.sample | 5 +++++ lib/galaxy/webapps/galaxy/config_schema.yml | 6 ++++++ scripts/get_uwsgi_args.py | 5 +++++ 4 files changed, 21 insertions(+) diff --git a/doc/source/admin/galaxy_options.rst b/doc/source/admin/galaxy_options.rst index 95436b2103d..405907fbf89 100644 --- a/doc/source/admin/galaxy_options.rst +++ b/doc/source/admin/galaxy_options.rst @@ -2388,6 +2388,11 @@ use_printdebug. It also causes the files used by PBS/SGE (submission script, output, and error) to remain on disk after the job is complete. + In addition, this will set uWSGI's `honour-stdin` option to + `true`; thus, preventing uWSGI from remapping stdin to `/dev/null` + and enabling debugging with tools like pdb. To keep uWSGI's + default setting, set `honor-stdin` to `false` in the `uwsgi` + section of this configuration file. :Default: ``false`` :Type: bool diff --git a/lib/galaxy/config/sample/galaxy.yml.sample b/lib/galaxy/config/sample/galaxy.yml.sample index bd2d9c22ce1..ac582b5ffea 100644 --- a/lib/galaxy/config/sample/galaxy.yml.sample +++ b/lib/galaxy/config/sample/galaxy.yml.sample @@ -1217,6 +1217,11 @@ galaxy: # use_printdebug. It also causes the files used by PBS/SGE # (submission script, output, and error) to remain on disk after the # job is complete. + # In addition, this will set uWSGI's `honour-stdin` option to `true`; + # thus, preventing uWSGI from remapping stdin to `/dev/null` and + # enabling debugging with tools like pdb. To keep uWSGI's default + # setting, set `honor-stdin` to `false` in the `uwsgi` section of this + # configuration file. #debug: false # Check for WSGI compliance. diff --git a/lib/galaxy/webapps/galaxy/config_schema.yml b/lib/galaxy/webapps/galaxy/config_schema.yml index 543c904c964..e97db7fc045 100644 --- a/lib/galaxy/webapps/galaxy/config_schema.yml +++ b/lib/galaxy/webapps/galaxy/config_schema.yml @@ -1731,6 +1731,12 @@ mapping: causes the files used by PBS/SGE (submission script, output, and error) to remain on disk after the job is complete. + In addition, this will set uWSGI's `honour-stdin` option to `true`; + thus, preventing uWSGI from remapping stdin to `/dev/null` and + enabling debugging with tools like pdb. To keep uWSGI's default + setting, set `honor-stdin` to `false` in the `uwsgi` section of this + configuration file. + use_lint: type: bool default: false diff --git a/scripts/get_uwsgi_args.py b/scripts/get_uwsgi_args.py index dd7f3f8aa2f..2ca9cf60934 100644 --- a/scripts/get_uwsgi_args.py +++ b/scripts/get_uwsgi_args.py @@ -118,6 +118,11 @@ def _get_uwsgi_args(cliargs, kwargs): # We always want to append client/src/assets as static-safe. __add_arg(args, 'static-safe', f'{os.getcwd()}/client/src/assets') + # Do not let uwsgi remap stdin to /dev/null if galaxy is in debug mode + galaxy_kwargs = load_app_properties(config_file=config_file, config_section='galaxy') + if __arg_set('debug', galaxy_kwargs) and not __arg_set('honour-stdin', uwsgi_kwargs): + __add_arg(args, 'honour-stdin', True) + for arg in DEFAULT_ARGS['_all_'] + DEFAULT_ARGS[cliargs.app]: if not __arg_set(arg, uwsgi_kwargs): __add_arg(args, arg, defaults[arg])