Incorrect user for supervisord celeryd

2024/10/3 12:29:28

I have some periodic tasks that I run with celery (daemonized by supervisord), but after trying to create a directory in the home dir for the user i setup for the supervisor'd process I got a "permission denied" error. After looking at the os.environ dict in a running celery task I noticed that the USER var is set to 'root' and not the user that I set up in my supervisord config for celery.

This is what my /usr/local/etc/supervisord.conf looks like:

[unix_http_server]
file=/tmp/supervisor.sock
chmod=0777[supervisord]
logfile=/var/log/supervisord.log
pidfile=/var/run/supervisord.pid[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface[supervisorctl]
serverurl=unix:///tmp/supervisor.sock[program:celery]
command=/home/<USER>/.virtualenvs/sync/bin/celeryd --beat --loglevel=INFO
environment=PYTHONPATH=/home/<USER>/apps/sync
directory=/home/<USER>/apps/sync
user=<USER>
numprocs=1
stdout_logfile=/var/log/celeryd.log
stderr_logfile=/var/log/celeryd.log
autostart=true
autorestart=true
startsecs=10
stopwaitsecs = 30

What could be causing this? Any help would be super appreciated!

Answer

I believe this is caused by the fact that you didn't set the HOME and USER environment variables. This is necessary when using the "user=" option if your subprocess relies on those being set.

After supervisord documentation on Subprocess Environment:

No shell is executed by supervisord when it runs a subprocess, so environment variables such as USER, PATH, HOME, SHELL, LOGNAME, etc. are not changed from their defaults or otherwise reassigned

So perhaps try:

environment=USER=<USER>,HOME=/home/<USER>,PYTHONPATH=/home/<USER>/apps/sync
https://en.xdnf.cn/q/70730.html

Related Q&A

Pandas drop rows where column contains *

Im trying to drop all rows from this df where column DB Serial contains the character *:DB Serial 0 13058 1 13069 2 *13070 3 13070 4 13044 5 13042I am using:df = df[~df[DB Serial…

How to stop scrapy spider after certain number of requests?

I am developing an simple scraper to get 9 gag posts and its images but due to some technical difficulties iam unable to stop the scraper and it keeps on scraping which i dont want.I want to increase t…

What is the difference between single and double bracket Numpy array?

import numpy as np a=np.random.randn(1, 2) b=np.zeros((1,2)) print("Data type of A: ",type(a)) print("Data type of A: ",type(b))Output:Data type of A: <class numpy.ndarray> D…

How to make tkinter button widget take up full width of grid

Ive tried this but it didnt help. Im making a calculator program. Ive made this so far: from tkinter import * window = Tk()disp = Entry(window, state=readonly, readonlybackground="white") dis…

Python strip() unicode string?

How can you use string methods like strip() on a unicode string? and cant you access characters of a unicode string like with oridnary strings? (ex: mystring[0:4] )

Python equivalent for MATLABs normplot?

Is there a python equivalent function similar to normplot from MATLAB? Perhaps in matplotlib?MATLAB syntax:x = normrnd(10,1,25,1); normplot(x)Gives:I have tried using matplotlib & numpy module to…

python mask netcdf data using shapefile

I am using the following packages:import pandas as pd import numpy as np import xarray as xr import geopandas as gpdI have the following objects storing data:print(precip_da)Out[]:<xarray.DataArray …

Whats a good general way to look SQLAlchemy transactions, complete with authenticated user, etc?

Im using SQLAlchemys declarative extension. Id like all changes to tables logs, including changes in many-to-many relationships (mapping tables). Each table should have a separate "log" table…

OpenCV - Tilted camera and triangulation landmark for stereo vision

I am using a stereo system and so I am trying to get world coordinates of some points by triangulation.My cameras present an angle, the Z axis direction (direction of the depth) is not normal to my sur…

Node.jss python child script outputting on finish, not real time

I am new to node.js and socket.io and I am trying to write a small server that will update a webpage based on python output. Eventually this will be used for a temperature sensor so for now I have a du…