Skip to content

Instantly share code, notes, and snippets.

@cornet
cornet / README.md
Created September 17, 2019 23:06 — forked from scintill/README.md
redirect syslog to stderr

LD_PRELOAD this as a library to output a binary's output from syslog() on stderr as well as any syslog daemon that's listening (useful for Docker, if you want all log output to be collected by Docker's standard output handling.) Beware though, if the program changes its stderr file descriptor (closes it, points it at /dev/null, pipes it out to a socket), this can have surprising results. For example, when I tried this with cyrus-imapd, I was getting syslog output sent to remote clients because stderr and stdout were remapped that way (not maintaing the original fd that Docker set up.)

Example Docker implementation

COPY syslog2stderr.c /build
RUN gcc -fPIC -shared /build/syslog2stderr.c -o /usr/local/lib/syslog2stderr.so
RUN echo /usr/local/lib/syslog2stderr.so >> /etc/ld.so.preload
@cornet
cornet / gist:1877458
Created February 21, 2012 17:07 — forked from chrisa/gist:1877183
diff -urN carbon-0.9.9/lib/carbon/protocols.py carbon-0.9.9-logpatch/lib/carbon/protocols.py
--- carbon-0.9.9/lib/carbon/protocols.py 2011-10-05 10:28:41.000000000 +0100
+++ carbon-0.9.9-logpatch/lib/carbon/protocols.py 2012-02-20 09:40:37.058970858 +0000
@@ -13,7 +13,6 @@
"""
def connectionMade(self):
self.peerName = self.getPeerName()
- log.listener("%s connection with %s established" % (self.__class__.__name__, self.peerName))
if state.metricReceiversPaused:
@cornet
cornet / delayed_job.rb
Created September 12, 2011 13:53 — forked from akmathur/delayed_job
Script to start/stop delayed_job
#!/usr/bin/env ruby
# -*- ruby -*-
require 'rubygems'
require 'daemon_spawn'
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment'))
class DelayedJobWorker < DaemonSpawn::Base
def start(args)
ENV['RAILS_ENV'] ||= args.first || 'development'
Dir.chdir Rails.root