芹菜-权限问题-创建文件夹 [英] Celery - Permission Problem - Create folder

查看:74
本文介绍了芹菜-权限问题-创建文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在centos7服务器上的网站(Django)的生产模式下使用 celery (职位经理).

I use celery (jobs manager) on prod mode for a website (Django) on a centos7 server.

我的问题是,在芹菜任务中,我的函数未创建文件夹(请参见 my_function ).

My problem is that in a celery task my function did not create folder (see my_function).

def my_fucntion():

    parent_folder = THE_PARENT_PATH

    if not os.path.exists(centrifuge_recentrifuge_work_dir_path):
        os.makedirs(centrifuge_recentrifuge_work_dir_path)
    # The folder THE_PARENT_PATH is created

    celery_task(parent_folder)

芹菜任务

@app.task(name='a task')
def celery_task(parent_folder):
    import getpass; print("permission : ", getpass.getuser())
    # permission : apache

    path_1 = os.path.join(parent_folder, "toto")

    if not os.path.exists(path_1):
        os.makedirs(path_1)
    # The folder path_1 is NOT created
    ..... some others instructions...
    # Singularity image run (needed the path_1 folder)

我使用Supervisord来实现芹菜的守护进程.

I use Supervisord for daemonization of celery.

[program:sitecelery]
command=/etc/supervisord.d/celery.sh
directory=/mnt/site/
user=apache
numprocs=1
stdout_logfile=/var/log/celery/worker.log
stderr_logfile=/var/log/celery/worker.log
autostart=true
autorestart=true
priority=999

文件夹 path_1 是在 user = root 时创建的,但我希望它不是烂文件,而是apache用户.

The folder path_1 is created when user=root but i want that it was not rot but apache user.

#!/bin/bash
cd /mnt/site/

exec ../myenv/bin/python3 -m celery -A site.celery_settings worker -l info --autoscale 20

sudo systemctl状态主管

● supervisord.service - Process Monitoring and Control Daemon
   Loaded: loaded (/usr/lib/systemd/system/supervisord.service; disabled; vendor preset: disabled)
   Active: active (running) since lun. 2018-10-15 09:09:05 CEST; 4min 59s ago
  Process: 61477 ExecStart=/usr/bin/supervisord -c /etc/supervisord.conf (code=exited, status=0/SUCCESS)
 Main PID: 61480 (supervisord)
   CGroup: /system.slice/supervisord.service
           ├─61480 /usr/bin/python /usr/bin/supervisord -c /etc/supervisord.conf
           └─61491 ../myenv/bin/python3 -m celery -A Site_CNR.celery_settings worker -l info --autoscale 20

oct. 15 09:09:05 web01 systemd[1]: Starting Process Monitoring and Control Daemon...
oct. 15 09:09:05 web01 systemd[1]: Started Process Monitoring and Control Daemon.
oct. 15 09:09:17 web01 Singularity[61669]: action-suid (U=48,P=61669)> Home directory is not owned by calling user: /usr/share/httpd
oct. 15 09:09:17 web01 Singularity[61669]: action-suid (U=48,P=61669)> Retval = 255
oct. 15 09:09:17 web01 Singularity[61678]: action-suid (U=48,P=61678)> Home directory is not owned by calling user: /usr/share/httpd
oct. 15 09:09:17 web01 Singularity[61678]: action-suid (U=48,P=61678)> Retval = 255

编辑1个操作系统.makedirs

在芹菜任务中:

if not os.path.exists(path_1):
    print("test")
    # test
    print(os.makedirs(path_1))
    # None
    os.makedirs(path_1)

os.makedirs 返回 None :/

推荐答案

我不知道为什么,但是使用 sudo chown -R apache:apache/usr/share/httpd解决了此问题的发布错误/解决此问题,oO

I dont know why but with this correction on a post error of this problem with a sudo chown -R apache:apache /usr/share/httpd/ resolve this problem oO

这篇关于芹菜-权限问题-创建文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆