Skip to content

Commit 218e79d

Browse files
Use /var/tmp directory for temporary server root directory on macOS.
1 parent 0c72bb3 commit 218e79d

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

docs/release-notes/version-4.6.5.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ Bugs Fixed
1414
``--mount-point``, the static files in the document root outside of the
1515
mount point for the WSGI application would no longer be accessible.
1616

17+
Features Changed
18+
----------------
19+
20+
* On macOS, use ``/var/tmp`` as default parent directory for server root
21+
directory rather than value of ``$TMPDIR``. The latter can produce a
22+
path which is too long and UNIX socket cannot be written there.
23+
1724
New Features
1825
------------
1926

src/server/__init__.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2394,8 +2394,9 @@ def check_percentage(option, opt_str, value, parser):
23942394
optparse.make_option('--server-root', metavar='DIRECTORY-PATH',
23952395
help='Specify an alternate directory for where the generated '
23962396
'web server configuration, startup files and logs will be '
2397-
'stored. Defaults to the sub directory specified by the '
2398-
'TMPDIR environment variable, or /tmp if not specified.'),
2397+
'stored. On Linux defaults to the sub directory specified by '
2398+
'the TMPDIR environment variable, or /tmp if not specified. '
2399+
'On macOS, defaults to the /var/tmp directory.'),
23992400

24002401
optparse.make_option('--server-mpm', action='append',
24012402
dest='server_mpm_variables', metavar='NAME', help='Specify '
@@ -2664,9 +2665,12 @@ def _cmd_setup_server(command, args, options):
26642665
options['port'], os.getuid())
26652666

26662667
if not options['server_root']:
2667-
tmpdir = os.environ.get('TMPDIR')
2668-
tmpdir = tmpdir or '/tmp'
2669-
tmpdir = tmpdir.rstrip('/')
2668+
if sys.platform == 'darwin':
2669+
tmpdir = '/var/tmp'
2670+
else:
2671+
tmpdir = os.environ.get('TMPDIR')
2672+
tmpdir = tmpdir or '/tmp'
2673+
tmpdir = tmpdir.rstrip('/')
26702674
options['server_root'] = '%s/mod_wsgi-%s:%s:%s' % (tmpdir,
26712675
options['host'], options['port'], os.getuid())
26722676

0 commit comments

Comments
 (0)