首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Celery -权限问题-创建文件夹

Celery -权限问题-创建文件夹
EN

Stack Overflow用户
提问于 2018-10-15 15:58:48
回答 1查看 381关注 0票数 1

对于centos7服务器上的网站(Django),我在prod模式下使用celery (作业管理器)。

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

函数

代码语言:javascript
复制
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)

芹菜任务

代码语言:javascript
复制
@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来实现芹菜的守护进程。

 celery.init

代码语言:javascript
复制
[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时创建的,但我希望它不是rot,而是apache用户。

celery.sh

代码语言:javascript
复制
#!/bin/bash
cd /mnt/site/

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

sudo systemctl状态监督器命令

代码语言:javascript
复制
● 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个os.makedirs

在芹菜任务中:

代码语言:javascript
复制
if not os.path.exists(path_1):
    print("test")
    # test
    print(os.makedirs(path_1))
    # None
    os.makedirs(path_1)

os.makedirs返回None :/

EN

回答 1

Stack Overflow用户

发布于 2018-10-15 17:48:10

我不知道为什么,但是通过对这个问题的post错误使用sudo chown -R apache:apache /usr/share/httpd/解决这个问题oO

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52812152

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档