2014-10-30 116 views
1

我正在使用Redis作爲virtualenv中的代理運行芹菜。我有一個通常的shell腳本來啓動芹菜。我有一個任務將臨時文件寫入$ HOME/.tmp。我使用mytask.delay(arg1,arg2)從Django python shell啓動芹菜任務。當我手動啓動芹菜時,該任務按預期工作 - 打開終端和./celeryd_start(如下所示)。但是,當我使用supervisor啓動芹菜時,任務失敗,因爲它無法寫入tmp文件。 Supervisor配置爲使用相同的shell腳本啓動芹菜,並在同一個用戶下手動啓動它。當芹菜在supervisord下運行時,芹菜任務無法寫入主目錄

我不知道發生了什麼,主管celery進程在用於手動啓動芹菜的同一個用戶下運行,它應該具有相同的權限。我嘗試在管理員配置文件中設置umask = 000,但這沒有改變。

是否有任何主管設置需要更改才能使其工作?

我嘗試將權限設置爲777,並將位置更改爲tmp無濟於事。該腳本使用以下命令創建臨時目錄。

mkdir -p $HOME/./tmp/ && chmod a+rx $HOME/.tmp/ 

監事配置:

[program:apl_dev_celeryd] 
; Set full path to celery program if using virtualenv 
command=/home/kp/apl/dev/bin/celeryd_start 
user=kp 
numprocs=1 
stdout_logfile=/home/kp/apl/dev/logs/worker_stdout.log 
stderr_logfile=/home/kp/apl/dev/logs/worker_stderr.log 
autostart=true 
autorestart=true 
startsecs=10 

stopwaitsecs = 10 

killasgroup=true 

priority=993 

celeryd_start

#!/bin/bash 

NAME="apl_dev_celeryd"        # Name of the application 
DJANGODIR=/home/kp/apl/dev/p     # Django project directory 
APP_NAME=p          # which celery app is run 
LOG_LEVEL=DEBUG         # valid values DEBUG, INFO, WARNING, ERROR, CRITICAL, FATAL 
CONCURRENCY=2         # number of worker processes 
echo "Starting $NAME as `whoami`" 

# Activate the virtual environment 
cd $DJANGODIR 
source ../bin/activate 
export PYTHONPATH=$DJANGODIR:$PYTHONPATH 

# Create the run directory if it doesn't exist 

# Start celeryd 
# Programs meant to be run under supervisor should not daemonize themselves (do not use --daemon) 
exec celery -A $APP_NAME worker --loglevel=$LOG_LEVEL --concurrency=$CONCURRENCY 

蟒蛇2.7.3 芹菜3.1.16 的Ubuntu 12.04

回答

1

貌似監督過程中不處理環境變量正確。

設置:

environment=HOME="/tmp/.tmp/" 

在上司的配置的過程中解決了這個問題。