我在 Digital Ocean 中托管了一个运行 Ubuntu 14.04 的 Droplet。
我有一个用于存储日志文件的gunicorn 日志目录,并且仅当所有者是运行gunicorn 进程的用户时才有效。
我愿意...
chown user gunicorn
但这只会持续到重新启动,然后所有权回到 root 并且该组是 adm。我正在运行 django 进程,但我不知道该怎么做。如何才能使对新所有者的更改永久生效,或者将用户添加到组 adm 也能正常工作?
目录路径是...
/var/log/gunicorn
ls -la Gunicorn 目录...
drwxr-x--- 2 root adm 4096 Jan 30 20:08 .
drwxrwxr-x 12 root syslog 4096 Jan 31 03:06 ..
-rw-r--r-- 1 django django 73747 Jan 31 02:34 access.log
-rw-r--r-- 1 django django 97698592 Jan 31 03:05 error.log
安装输出..
/dev/vda1 on / type ext4 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /sys/fs/cgroup type tmpfs (rw)
none on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
udev on /dev type devtmpfs (rw,mode=0755)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755)
none on /run/lock type tmpfs (rw,noexec,nosuid,nodev,size=5242880)
none on /run/shm type tmpfs (rw,nosuid,nodev)
none on /run/user type tmpfs (rw,noexec,nosuid,nodev,size=104857600,mode=0755)
none on /sys/fs/pstore type pstore (rw)
systemd on /sys/fs/cgroup/systemd type cgroup (rw,noexec,nosuid,nodev,none,name=systemd)
ls -la /var/log | ls -la /var/log | grep 古尼康...
drwxr-x--- 2 root adm 4096 Jan 30 20:08 gunicorn
/etc/init/gunicorn.conf...
description "Gunicorn daemon for Django project"
start on (local-filesystems and net-device-up IFACE=eth0)
stop on runlevel [!12345]
# If the process quits unexpectadly trigger a respawn
respawn
setuid django
setgid django
chdir /home/django
exec venv/bin/gunicorn \
--name=langalang \
--pythonpath=langalang \
--bind=0.0.0.0:9000 \
--config /etc/gunicorn.d/gunicorn.py \
langalang.wsgi:application
/etc/gunicorn.d/cunicorn.py...
"""gunicorn WSGI server configuration."""
from multiprocessing import cpu_count
from os import environ
def max_workers():
return cpu_count() * 2 + 1
max_requests = 1000
worker_class = 'gevent'
workers = max_workers()
errorlog = '/var/log/gunicorn/error.log'
accesslog = '/var/log/gunicorn/access.log'
答案1
事实证明,/etc/init.d/gunicorn 中有一个脚本,每次gunicorn 启动时都会创建并授予目录权限。我刚刚更改了该文件中的权限,一切正常。那真的很难找到