Berco Beute
Berco Beute

Reputation: 1195

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

Upvotes: 7

Views: 8636

Answers (4)

Abhishek J
Abhishek J

Reputation: 2584

I used this hacky way to get it to work. It works in Debian Jessie as well.

I simply pasted the guy's file to one of my own in my project directory. Like /app/supervisord_stdout.py

I then added it to the conf like this. /app is the project directory for my project files in the container.

[eventlistener:stdout]
command = python supervisord_stdout.py
buffer_size = 100
events = PROCESS_LOG
directory=/app
result_handler=supervisord_stdout:event_handler
environment=PYTHONPATH=/app

Upvotes: 1

James Dunmore
James Dunmore

Reputation: 1310

Very similar to the above, but I don't think that there is a complete answer.

I had to remove from apt

apt-get remove supervisor

Then reinstall with pip, but with pip2 as the current version of supervisor doesn't support python 3

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

This all then worked.

Although the supervisord path is now

/usr/local/bin/supervisord

Hope that helps.

Upvotes: 1

João Antunes
João Antunes

Reputation: 851

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!

Upvotes: 8

Alexandre Bulté
Alexandre Bulté

Reputation: 1442

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.

Upvotes: 1

Related Questions