EzDevInfo.com

supervisord interview questions

Top supervisord frequently asked interview questions

Is there Windows analog to supervisord?

I need to run python script and be sure that it will restart after it terminates. I know that there is UNIX solution called supervisord. But unfortunately server where my script has to be run is on Windows. Do you know what tool can be useful? Thanks


Source: (StackOverflow)

How to use environment variables with supervisor, gunicorn and django (1.6)

I want to configure supervisor to control gunicorn in my django 1.6 project using an environment variable for SECRET_KEY.

I set my secret key in .bashrc as

export SECRET_KEY=[my_secret_key] 

And I have a shell script to start gunicorn:

NAME="myproject"
LOGFILE=/home/django/myproject/log/gunicorn.log
LOGDIR=$(dirname $LOGFILE)
NUM_WORKERS=3
DJANGO_WSGI_MODULE=myproject.wsgi

USER=django
GROUP=django
IP=0.0.0.0
PORT=8001

echo "Starting $NAME"

cd /home/django/myproject/myproject
source /home/django/.virtualenvs/myproject/bin/activate

test -d $LOGDIR || mkdir -p $LOGDIR

exec gunicorn ${DJANGO_WSGI_MODULE} \
 --name $NAME \
 --workers $NUM_WORKERS \
 --user=$USER --group=$GROUP \
 --log-level=debug \
 --bind=$IP:$PORT
 --log-file=$LOGFILE 2>>$LOGFILE

Then to configure my project's gunicorn server in supervisor:

[program:my_django_project]
directory=/home/django/my_django_project/my_django_project
command=/home/django/my_django_project/my_django_project/gunicorn.sh
user=django
autostart=true
autorestart=true
stdout_logfile=/home/django/my_django_project/log/supervisord.log
stderr_logfile=/home/django/my_django_project/log/supervisor_error.log

If I start gunicorn using my shell script it doesn't throw any error but when I start it with supervisor it fails and I see in the logs that it doesn't "find" my SECRET_KEY.

What's the correct way to configure supervisor to read my shell variables (I wan't to keep them in my .bashrc unless there's a more appropriate way)?


Source: (StackOverflow)

Advertisements

Supervisor and Environment Variables

I really don't know how to get supervisor to work with environment variables.

Below is a configuration snippet.

[program:htNotificationService]
priority=2
#autostart=true
#autorestart=true
directory=/home/ubuntu/workspace/htFrontEnd/heythat/htsite
command = /usr/bin/python htNotificationService.py -service
stdout_logfile=/var/log/heythat/htNotificationService.log
redirect_stderr=true
environment=PATH=/home/ubuntu/workspace/htFrontEnd/heythat
stopsignal=QUIT

I have tried the following:

environment=PATH=/home/ubuntu/workspace/htFrontEnd/heythat
environment=PYTHONPATH=$PYTHONPATH:/home/ubuntu/workspace/htFrontEnd/heythat
environment=PATH=/home/ubuntu/workspace/htFrontEnd/heythat,PYTHONPATH=$PYTHONPATH:/home/ubuntu/workspace/htFrontEnd/heythat

When I start supervisor I get

htNotificationService: ERROR (abnormal termination)

I can start from the shell by setting the python path, but not from supervisor. In the logs I get an error that says that an import can't be found. Well, that would be solved if supervisor would work. I even have the path in /etc/environments?

Why will supervisor not work?


Source: (StackOverflow)

supervisord stopping child processes

One of the problems, I face with supervisord is that when I have a command which in turn spawns another process, supervisord is not able to kill it.

For example I have a java process which when runs normally is like

 $ zkServer.sh start-foreground
 $ ps -eaf | grep zk
 user 30404 28280  0 09:21 pts/2    00:00:00 bash zkServer.sh start-foreground
 user 30413 30404 76 09:21 pts/2    00:00:10 java -Dzookeeper.something..something

The supervisord config file looks like:

[program:zookeeper]
command=zkServer.sh start-foreground
autorestart=true
stopsignal=KILL

These kind of processes which have multiple childs are not well handled by supervisord when it comes to stopping them from supervisorctl. So when I run this from the supervisord and try to stop it from supervisorctl, only the top level process gets killed but not the actual java process.


Source: (StackOverflow)

Supervisorctl not respecting my configuration

I have set the following in /home/david/conf/supervisor.conf:

[unix_http_server]
file=/home/david/tmp/supervisor.sock

[supervisord]
logfile=/home/david/tmp/supervisord.log  ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB                    ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10                       ; (num of main logfile rotation backups;default 10)
loglevel=info                            ; (log level;default info; others: debug,warn,trace)
pidfile=/home/david/tmp/supervisord.pid  ; (supervisord pidfile;default supervisord.pid)
nodaemon=false                           ; (start in foreground if true;default false)
minfds=1024                              ; (min. avail startup file descriptors;default 1024)
minprocs=200
childlogdir=/home/david/tmp

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl=unix:///home/david/tmp/supervisor.sock

And started :

$ supervisord -c /home/david/conf/supervisor.conf

However how come supervisorctl still uses the default http://localhost:9001 as the serverurl?

$ supervisorctl
http://localhost:9001 refused connection
supervisor>

I checked /home/david/tmp and the files supervisord.log and supervisord.pid do exist.


Source: (StackOverflow)

How to set environment variables in Supervisor service

How do you export environment variables in the command executed by Supervisor? I first tried:

command="export SITE=domain1; python manage.py command"

but Supervisor reports "can't find command".

So then I tried:

command=/bin/bash -c "export SITE=domain1; python manage.py command"

and the command runs, but this seems to interfere with the daemonization since when I stop the Supervisor daemon, all the other daemons it's running aren't stopped.


Source: (StackOverflow)

nginx and supervisor setup in Ubuntu

I'm using django-gunicorn-nginx setup by following this tutorial http://ijcdigital.com/blog/django-gunicorn-and-nginx-setup/ Upto nginx setup, it is working. Then I installed supervisor, configured it and then I reboot my server and checked, it shows 502 bad gateway. I'm using Ubuntu 12.04 LTS

/etc/supervisor/conf.d/qlimp.conf

[program: qlimp]
directory = /home/nirmal/project/qlimp/qlimp.sh
user = nirmal
command = /home/nirmal/project/qlimp/qlimp.sh
stdout_logfile = /path/to/supervisor/log/file/logfile.log
stderr_logfile = /path/to/supervisor/log/file/error-logfile.log

Then I restarted supervisor and I run this command $ supervisorctl start qlimp and I'm getting this error

unix:///var/run/supervisor.sock no such file

Is there any problem in my supervisor setup?

Thanks!


Source: (StackOverflow)

Supervising virtualenv django app via supervisor

I'm trying to use supervisor in order to manage my django project running gunicorn inside a virtualenv. My conf file looks like this:

[program:diasporamas]
command=/var/www/django/bin/gunicorn_django
directory=/var/www/django/django_test
process_name=%(program_name)s
user=www-data
autostart=false
stdout_logfile=/var/log/gunicorn_diasporamas.log
stdout_logfile_maxbytes=1MB
stdout_logfile_backups=2
stderr_logfile=/var/log/gunicorn_diasporamas_errors.log
stderr_logfile_maxbytes=1MB
stderr_logfile_backups=2enter code here

The problem is, I need supervisor to launch the command after it has run 'source bin/activate' in my virtualenv. I've been hanging around google trying to find an answer but didn't find anything.

Note: I don't want to use virtualenvwrapper

Any help please?


Source: (StackOverflow)

What is the difference between Upstart and Supervisord? [closed]

Are Upstart and Supervisord interchangeable? Do they work together? I am looking to run a python program as root when my system (debian) boots. After the boot, I would like the process manager to continue running the program if it crashes. Which would be better suited to do this?


Source: (StackOverflow)

what is the advantage of using supervisord over monit

We have a custom setup which has several deamons (web apps + background tasks) running. I am looking at using a service which helps us to monitor those deamons and restart them if their resource consumption exceeds over a level.

I will appreciate any insight on when one is better over the other. As I understand monit spins up a new process while supervisord starts a sub process. What is the pros and cons of this approach ?

I will also be using upstart to monitor monit or supervisord itself. The webapp deployment will be done using capistrano.

Thanks


Source: (StackOverflow)

Supervisor socket error issue

$ supervisorctl reread
error: <class 'socket.error'>, [Errno 111] Connection refused: file: /usr/lib64/python2.6/socket.py line: 567

I'm trying to configure supervisor on my production system, but am hitting this error. The supervisor log file is empty.

When I just type supervisorctl, it complains:

http://localhost:9001 refused connection

Nothing is currently listening on port 9001, AFACT: lsof | grep TCP returns nothing.


Source: (StackOverflow)

how to restart only certain processes using supervisorctl?

I'm running a few processes using supervisord, named process1, process2, ..., process8. If I want to restart process{1-4}, how can I do that with supervisorctl?


Source: (StackOverflow)

Have Supervisord Periodically restart child processes

I am using Supervisor (3.0a12) on ubuntu 12.04 to manage php gearman workers. Sometimes the workers get caught in a weird state where they use tons of cpu and ram. While I am figuring this issue out I thought it would be nice to have Supervisor automatically kill and refresh workers occasionally. I looked at http://supervisord.org/configuration.html the configuration documentation and didn't seem to see any options that would allow for this.

Does anyone know if it is possible to have supervisord periodically restart all processes it governs??


Source: (StackOverflow)

python supervisord program dependency

I have [program:A], [program:B] in my supervisord.conf

B depend A, means:

A should start before B.

How to ensure this by supervisor?


Source: (StackOverflow)

Will reloading supervisord cause the process under its to stop?

I try to figure out when I used reload command to supervisord. Will it stop the processing currently executing under it? I used below steps:

mlzboy@mlzboy-mac:~/my/ide/test$ pstree -p|grep super
        |-supervisord(6763)
mlzboy@mlzboy-mac:~/my/ide/test$ supervisorctl 
daemon                           STARTING   
supervisor> reload
Really restart the remote supervisord process y/N? y
Restarted supervisord
supervisor> exit
mlzboy@mlzboy-mac:~/my/ide/test$ pstree -p|grep super
        |-supervisord(6763)

I found that the process id is not changed. So does it prove reload will not stop the processing under supervisor control?


Source: (StackOverflow)