Skip to content

Commit 56a3063

Browse files
committed
Initial commit.
0 parents  commit 56a3063

File tree

4 files changed

+99
-0
lines changed

4 files changed

+99
-0
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*.pyc
2+
*.pyo
3+
*.egg-info
4+
build/
5+
pkg/

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# supervisor-stdout
2+
3+
A simple [supervisord](http://supervisord.org/) event listener to relay
4+
process output to supervisor's stdout.
5+
6+
This is useful in situations where the output will be collected and set to
7+
external logging framework, such as Heroku.
8+
9+
## Installation
10+
11+
Just install via pip or add to your requirements.txt:
12+
13+
pip install supervisor-stdout
14+
15+
## Usage
16+
17+
An example supervisord.conf:
18+
19+
[supervisord]
20+
nodaemon = true
21+
22+
[program:web]
23+
command = ...
24+
stdout_events_enabled = true
25+
stderr_events_enabled = true
26+
27+
[eventlistener:stdout]
28+
command = supervisor_stdout
29+
buffer_size = 100
30+
events = PROCESS_LOG
31+
result_handler = supervisor_stdout:event_handler

setup.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env python
2+
# -*- coding: iso-8859-1 -*-
3+
import os
4+
5+
from setuptools import setup
6+
7+
setup(
8+
name = 'supervisor-stdout',
9+
version = '0.1',
10+
py_modules = ['supervisor-stdout'],
11+
12+
author = 'Noah Kantrowitz',
13+
author_email = 'noah@coderanger.net',
14+
description = '',
15+
long_description = open(os.path.join(os.path.dirname(__file__), 'README.md')).read(),
16+
license = 'BSD',
17+
keywords = '',
18+
url = 'https://github.com/coderanger/supervisor-stdout',
19+
classifiers = [
20+
'Development Status :: 1 - Planning',
21+
# 'Development Status :: 2 - Pre-Alpha',
22+
# 'Development Status :: 3 - Alpha',
23+
# 'Development Status :: 4 - Beta',
24+
# 'Development Status :: 5 - Production/Stable',
25+
# 'Development Status :: 6 - Mature',
26+
# 'Development Status :: 7 - Inactive',
27+
'Environment :: Web Environment',
28+
'License :: OSI Approved :: BSD License',
29+
'Natural Language :: English',
30+
'Operating System :: OS Independent',
31+
'Programming Language :: Python',
32+
],
33+
entry_points = {
34+
'console_scripts': [
35+
'supervisor_stdout = supervisor_stdout:main',
36+
]
37+
}
38+
)

supervisor_stdout.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import sys
2+
3+
def write_stdout(s):
4+
sys.stdout.write(s)
5+
sys.stdout.flush()
6+
7+
def write_stderr(s):
8+
sys.stderr.write(s)
9+
sys.stderr.flush()
10+
11+
def main():
12+
while 1:
13+
write_stdout('READY\n') # transition from ACKNOWLEDGED to READY
14+
line = sys.stdin.readline() # read header line from stdin
15+
headers = dict([ x.split(':') for x in line.split() ])
16+
data = sys.stdin.read(int(headers['len'])) # read the event payload
17+
write_stdout('RESULT %s\n%s'%(len(data), data)) # transition from READY to ACKNOWLEDGED
18+
19+
def event_handler(event, response):
20+
line, data = response.split('\n', 1)
21+
headers = dict([ x.split(':') for x in line.split() ])
22+
print '%s %s | %s'%(headers['processname'], headers['channel'], data),
23+
24+
if __name__ == '__main__':
25+
main()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy