Commit 280685a7 authored by Srikanth Raju's avatar Srikanth Raju Committed by Leigh Stoller

Do syslog stuff for meta server

parent 00197599
......@@ -9,7 +9,7 @@ my @LOGFILES = ("$LOGDIR/bootinfo.log", "$LOGDIR/tmcd.log",
"$LOGDIR/capture.log", "$LOGDIR/dhcpd.log", "$LOGDIR/capserver.log",
"$LOGDIR/frisbeed.log", "$LOGDIR/mfrisbeed.log", "$LOGDIR/proxydhcpd.log",
"$LOGDIR/stated.log", "$LOGDIR/stated-mail.log",
"$LOGDIR/osselect.log", "$LOGDIR/power.log",
"$LOGDIR/osselect.log", "$LOGDIR/power.log", "$LOGDIR/tmcd-meta.log",
"$LOGDIR/tftpd.log", "$LOGDIR/sdcollectd.log", "$LOGDIR/genlastlog.log",
"$LOGDIR/sshxmlrpc.log", "$LOGDIR/plabgetfree.log", "$LOGDIR/xmlrpcbag.log",
"$LOGDIR/plabrenew.log", "$LOGDIR/sslxmlrpc.log", "$LOGDIR/pubsubd.log",
......@@ -86,6 +86,7 @@ sub Install($$$)
my @syslog_lines = (
"!bootinfo", "*.*\t\t\t\t\t\t$LOGDIR/bootinfo.log",
"!tmcd", "*.*\t\t\t\t\t\t$LOGDIR/tmcd.log",
"!tmcd-meta", "*.*\t\t\t\t\t\t$LOGDIR/tmcd-meta.log",
"!capture", "*.*\t\t\t\t\t\t$LOGDIR/capture.log",
"!dhcpd", "*.*\t\t\t\t\t\t$LOGDIR/dhcpd.log",
"!proxydhcpd","*.*\t\t\t\t\t\t$LOGDIR/proxydhcpd.log",
......@@ -142,6 +143,7 @@ sub Install($$$)
DoneIfEdited($NEWSYSLOG_CONF);
AppendToFileFatal($NEWSYSLOG_CONF,
"$LOGDIR/tmcd.log 640 9 1000 * Z",
"$LOGDIR/tmcd-meta.log 640 9 1000 * Z",
"$LOGDIR/stated.log 640 9 1000 * Z ".
"/var/run/stated.pid 31",
"$LOGDIR/stated-mail.log 640 9 1000 * Z ".
......
......@@ -4,18 +4,23 @@ import urlparse
import traceback
import os
import sys
import syslog
import mysql.connector
import daemon
from lockfile import pidlockfile
# This requires Python 2.6+
class Ec2MetaHandler(BaseHTTPRequestHandler):
def __init__(self, req, ca, huh):
self.cnx = mysql.connector.connect(user='tmcd',
database='tbdb', unix_socket='/tmp/mysql.sock')
facil = "LOG_" + "@TBLOGFACIL@".upper()
syslog.openlog("tmcd-meta", syslog.LOG_PID, getattr(syslog,facil))
BaseHTTPRequestHandler.__init__(self,req,ca,huh)
def log_message(self, format, *args):
syslog.syslog(format.format(args))
def do_GET(self):
parsed_path = urlparse.urlparse(self.path)
......@@ -38,7 +43,7 @@ class Ec2MetaHandler(BaseHTTPRequestHandler):
message = self.handle_req(folders, self.metas)
message = message + "\n"
except Exception as e:
print traceback.format_exc()
syslog.syslog(traceback.format_exc())
self.send_response(404)
self.end_headers()
return
......@@ -217,6 +222,9 @@ if __name__ == '__main__':
import socket
metad = daemon.DaemonContext()
metad.pidfile = pidlockfile.PIDLockFile('/var/run/tmcd-meta.pid')
metad.stdout = tmplog
metad.stderr = tmplog
with metad:
server = HTTPServer((socket.gethostbyname(socket.gethostname()), 8787),
Ec2MetaHandler)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment