Python – Running supervisord process as root

batch-processingpythonsupervisord

My goal is to run sudo inside one of the programs:

[program:doStaff]
command=sudo python manage.py doStaff
autostart=true
autorestart=true
stderr_logfile=/var/log/doStaff.err.log
stdout_logfile=/var/log/doStaff.out.log

Here is [unix_http_server] from supervisord.conf:

[unix_http_server]
file=/var/run/supervisor.sock  
chmod=0770   

Tried to set the supervisord user to root inside supervisord.conf but it didn't help.

I am trying to run this process as root since this script deletes some files in the system.

Best Answer

In your program config (program:doStaff) add this line:

user=root