Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot receive a event notification #622

Closed
detailyang opened this issue Jun 1, 2015 · 4 comments
Closed

Cannot receive a event notification #622

detailyang opened this issue Jun 1, 2015 · 4 comments
Labels

Comments

@detailyang
Copy link

Hi, i need to receive a process state event. So i use the event listener to do this. But now i can only receive the event about the event listener self, not other process. my configure file is below:

[program:sample]
directory=/data/
command=/bin/bash -c 'while sleep 1; do echo "test"; done'
redirect_stderr=true
log_stdout=true             ; if true, log program stdout (default true)
log_stderr=true             ; if true, log program stderr (def false)
stdout_logfile=/data/logs/supervisord/sample.log    ; child log path, use NONE for none; default AUTO
stdout_logfile_maxbytes=50MB        ; max # logfile bytes b4 rotation (default 50MB)
stdout_logfile_backups=3         ; # of logfile backups (default 10)

[program:cat]
directory=/data/
command=/bin/cat
redirect_stderr=true
log_stdout=true             ; if true, log program stdout (default true)
log_stderr=true             ; if true, log program stderr (def false)
stdout_logfile=/data/logs/supervisord/cat.log    ; child log path, use NONE for none; default AUTO
stdout_logfile_maxbytes=50MB        ; max # logfile bytes b4 rotation (default 50MB)
stdout_logfile_backups=3         ; # of logfile backups (default 10)

[eventlistener:event]
command=/opt/python/bin/python /etc/supervisord.d/event.py
events=PROCESS_STATE
redirect_stderr=true
log_stdout=true             ; if true, log program stdout (default true)
log_stderr=true             ; if true, log program stderr (def false)
stdout_logfile=/data/logs/supervisord/x.log    ; child log path, use NONE for none; default AUTO
stdout_logfile_maxbytes=50MB        ; max # logfile bytes b4 rotation (default 50MB)
stdout_logfile_backups=3         ; # of logfile backups (default 10)
buffer_size=10

my event.py


#! /opt/python/bin/python
import sys
from supervisor.childutils import listener

def write_stdout(s):
    sys.stdout.write(s)
    sys.stdout.flush()


def write_stderr(s):
    sys.stderr.write(s)
    sys.stderr.flush()


def main():
    while True:
        headers, body = listener.wait(sys.stdin, sys.stdout)
        body = dict([pair.split(":") for pair in body.split(" ")])

        write_stderr("Headers: %r\n" % repr(headers))
        write_stderr("Body: %r\n" % repr(body))

        if headers["eventname"] == "PROCESS_STATE_RUNNING":
            write_stderr("Process state running...\n")

if __name__ == '__main__':
    main()

my log


READY
Headers: "{'ver': '3.0', 'poolserial': '0', 'len': '60', 'server': 'supervisor', 'eventname': 'PROCESS_STATE_STARTING', 'serial': '117', 'pool': 'event'}"
Body: "{'from_state': 'STOPPED', 'processname': 'event', 'tries': '0', 'groupname': 'event'}"
READY
READY
Headers: "{'ver': '3.0', 'poolserial': '0', 'len': '60', 'server': 'supervisor', 'eventname': 'PROCESS_STATE_STARTING', 'serial': '133', 'pool': 'event'}"
Body: "{'from_state': 'STOPPED', 'processname': 'event', 'tries': '0', 'groupname': 'event'}"
READY
READY
Headers: "{'ver': '3.0', 'poolserial': '0', 'len': '60', 'server': 'supervisor', 'eventname': 'PROCESS_STATE_STARTING', 'serial': '145', 'pool': 'event'}"
Body: "{'from_state': 'STOPPED', 'processname': 'event', 'tries': '0', 'groupname': 'event'}"
READY

as you see, i cannot receive the sample process event notification, although i use the comand supervisorctl restart sample
guys, any idea?

@mnaberez mnaberez added the events label Jun 1, 2015
@mnaberez
Copy link
Member

mnaberez commented Jun 1, 2015

Related: #252

@detailyang
Copy link
Author

@mnaberez thx. but this issue is published on 2 Jul 2013, so can any idea solve this?

@detailyang
Copy link
Author

holy shit, now i know the reason why i cannot recevie the event. According the protocol, you cannot write other data to the stdout except READY,RESULT and so on...

@mnaberez
Copy link
Member

mnaberez commented Jun 2, 2015

supervisord will now halt with an error message if redirect_stderr=true is set in an [eventlistener:x] section. This was committed in 4420af4 and will be released in Supervisor 3.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants