ochinchina / supervisord

a go-lang supervisor implementation
MIT License
4.03k stars 571 forks source link

No log message reported - openshift/k8s #98

Open cmoulliard opened 6 years ago

cmoulliard commented 6 years ago

When I build the following image to start supervisord and launch the docker container as a pod on k8s/openshift, no log is reported using oc logs command

oc logs supervisord-pod

Docker also doesn't display log messages excepted when we kill the process

docker run -it 172.30.1.1:5000/k8s-supervisor/supervisord:v1
^CINFO[2018-06-27T12:13:51Z] receive a signal to stop all process & exit   signal=interrupt

Dockerfile

FROM debian:latest
ADD echo.sh /tmp/echo.sh
ADD supervisor.conf /tmp/supervisor.conf
COPY --from=ochinchina/supervisord:latest /usr/local/bin/supervisord /usr/local/bin/supervisord
CMD ["/usr/local/bin/supervisord","-c /tmp/supervisor.conf"]

Supervisor.conf file

[program:echo]
command = /tmp/echo.sh

echo.sh file

#!/bin/bash
echo "Hello, World!"

To create the pod

oc create -f pod.yml
where pod.yml is

apiVersion: v1
kind: Pod
metadata:
  name: supervisord-pod
  labels:
    app: odo-tool
spec:
  containers:
  - name: supervisord-container
    image: 172.30.1.1:5000/k8s-supervisor/supervisord:v1

Of course, we get log messages when supervisord is started locally

./bin/supervisord -c supervisord.conf
INFO[2018-06-27T14:09:21+02:00] create process:echo
INFO[2018-06-27T14:09:21+02:00] try to start program                          program=echo
INFO[2018-06-27T14:09:21+02:00] success to start program                      program=echo
DEBU[2018-06-27T14:09:22+02:00] wait program exit                             program=echo
INFO[2018-06-27T14:09:22+02:00] program stopped with status:exit status 0     program=echo
INFO[2018-06-27T14:09:22+02:00] Don't start the stopped program because its autorestart flag is false  program=echo

QUESTIONS:

cmoulliard commented 6 years ago

Problem resolved by doing this modification to the dockerfile

CMD -> ENTRYPOINT
ENTRYPOINT ["/usr/local/bin/supervisord","-c","/tmp/supervisor.conf"]

and to stdout the message from the bash script

[program:echo]
command = /tmp/echo.sh
stdout_logfile=/dev/stdout
stdout_events_enabled=true

REMARK: should be good to enhance the doc !

ochinchina commented 6 years ago

@cmoulliard any suggestion for document improvement?