From 2e0dcceee3c0eedfbba0e6cd5ab199b559ece51e Mon Sep 17 00:00:00 2001 From: Siva Mahadevan Date: Tue, 9 Jul 2024 17:57:38 -0400 Subject: [PATCH] don't fail upon error while chdir()ing *before* loading config --- gunicorn/app/base.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/gunicorn/app/base.py b/gunicorn/app/base.py index dbd05bc7f..da5d5b36e 100644 --- a/gunicorn/app/base.py +++ b/gunicorn/app/base.py @@ -161,7 +161,15 @@ def load_config(self): cfg = self.init(parser, args, args.args) # set up import paths and follow symlinks - self.chdir() + try: + self.chdir() + except Exception as e: + msg = "Warning: failed to chdir to default path '%s'" \ + " before loading config: %s\n" \ + "Continuing with current working directory." \ + % (sys.cfg.chdir, e) + print(msg, file=sys.stderr) + sys.stderr.flush() # Load up the any app specific configuration if cfg: