Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker, Supervisord and supervisor-stdout

I'm trying to centralize output from supervisord and its processes using supervisor-stdout. But with this supervisord configuration:

#supervisord.conf

[supervisord]
nodaemon = true

[program:nginx]
command = /usr/sbin/nginx
stdout_events_enabled = true
stderr_events_enabled = true

[eventlistener:stdout]
command = supervisor_stdout
buffer_size = 100
events = PROCESS_LOG
result_handler = supervisor_stdout:event_handler

(Note that the config section of supervisor-stoud is exactly the same as the example on the supervisor-stoud site).

...and this Dockerfile:

#Dockerfile

FROM python:3-onbuild

RUN apt-get update && apt-get install -y nginx supervisor

# Setup supervisord
RUN pip install supervisor-stdout
RUN mkdir -p /var/log/supervisor
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY nginx.conf /etc/nginx/nginx.conf

# restart nginx to load the config
RUN service nginx stop

# Start processes
CMD supervisord -c /etc/supervisor/conf.d/supervisord.conf -n

I can build the image just fine, but running a container from it gives me:

Error: supervisor_stdout:event_handler cannot be resolved within [eventlistener:stdout]

EDIT

The output from running:

supervisord -c /etc/supervisor/conf.d/supervisord.conf -n

is:

Error: supervisor_stdout:event_handler cannot be resolved within [eventlistener:stdout]
For help, use /usr/bin/supervisord -h
like image 761
Berco Beute Avatar asked Apr 22 '15 07:04

Berco Beute


2 Answers

I had the same problem, in short, you need to install the Python package that provides that supervisor_stdout:event_handler handler. You should be able to by issuing the following commands:

apt-get install -y python-pip
pip install supervisor-stdout

If you have pip installed on that container, a simple:

pip install supervisor-stdout should suffice, more info about that specific package can be found here:

https://pypi.python.org/pypi/supervisor-stdout

AFAIK, there is no debian package that provides the supervisor-stdout, so the easiest method to install it is through pip.

Hope it helps whoever comes here as I did.

[Edit] As Vin-G suggested, if you still have a problem even after going through these steps, supervisord might be stuck in an old version. Try updating it.

Cheers!

like image 187
João Antunes Avatar answered Sep 20 '22 03:09

João Antunes


I had the exact same problem and solved it by using Ubuntu 14.04 as a base image instead of Debian Jessie (I was using python:2.7 image which is based on Jessie).

You can refer to this complete working implementation: https://github.com/rehabstudio/docker-gunicorn-nginx.

EDIT: as pointed out by @Vin-G in his comment, it might be because the supervisor version shipped with Debian Jessie is too old. You could try to remove it from apt and install it with pip instead.

like image 29
Alexandre Bulté Avatar answered Sep 24 '22 03:09

Alexandre Bulté