mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
Make WorkerTmp accept a configurable tmp dir
This commit is contained in:
parent
f7d9979d5b
commit
f1e2073047
@ -801,6 +801,18 @@ class Pidfile(Setting):
|
||||
If not set, no PID file will be written.
|
||||
"""
|
||||
|
||||
class WorkerTmpDir(Setting):
|
||||
name = "worker_tmp_dir"
|
||||
section = "Server Mechanics"
|
||||
cli = ["--worker-tmp-dir"]
|
||||
meta = "DIR"
|
||||
validator = validate_string
|
||||
default = None
|
||||
desc = """\
|
||||
A directory to use for the worker heartbeat temporary file.
|
||||
|
||||
If not set, the default temporary directory will be used.
|
||||
"""
|
||||
|
||||
class User(Setting):
|
||||
name = "user"
|
||||
|
||||
@ -19,7 +19,10 @@ class WorkerTmp(object):
|
||||
|
||||
def __init__(self, cfg):
|
||||
old_umask = os.umask(cfg.umask)
|
||||
fd, name = tempfile.mkstemp(prefix="wgunicorn-")
|
||||
fdir = cfg.worker_tmp_dir
|
||||
if fdir and not os.path.isdir(fdir):
|
||||
raise RuntimeError("%s doesn't exist. Can't create workertmp." % fdir)
|
||||
fd, name = tempfile.mkstemp(prefix="wgunicorn-", dir=fdir)
|
||||
|
||||
# allows the process to write to the file
|
||||
util.chown(name, cfg.uid, cfg.gid)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user