All new accounts created on Gitlab now require administrator approval. If you invite any collaborators, please let Flux staff know so they can approve the accounts.

Commit 00197599 authored by Srikanth Raju's avatar Srikanth Raju Committed by Leigh B Stoller

Make the meta server a daemon

parent 920c5185
#!/usr/local/bin/python
from BaseHTTPServer import BaseHTTPRequestHandler
import urlparse
import traceback
import os
import sys
import mysql.connector
import daemon
from lockfile import pidlockfile
class Ec2MetaHandler(BaseHTTPRequestHandler):
......@@ -14,8 +17,6 @@ class Ec2MetaHandler(BaseHTTPRequestHandler):
BaseHTTPRequestHandler.__init__(self,req,ca,huh)
def do_GET(self):
parsed_path = urlparse.urlparse(self.path)
......@@ -214,21 +215,11 @@ class Ec2MetaHandler(BaseHTTPRequestHandler):
if __name__ == '__main__':
from BaseHTTPServer import HTTPServer
import socket
server = HTTPServer((socket.gethostbyname(socket.gethostname()), 8787), Ec2MetaHandler)
pid = str(os.getpid())
pidfile = "/var/run/tmcd-meta.pid"
if os.path.isfile(pidfile):
print "%s already exists, exiting" % pidfile
sys.exit()
else:
file(pidfile, 'w').write(pid)
try:
print 'Starting server, use <Ctrl-C> to stop'
metad = daemon.DaemonContext()
metad.pidfile = pidlockfile.PIDLockFile('/var/run/tmcd-meta.pid')
with metad:
server = HTTPServer((socket.gethostbyname(socket.gethostname()), 8787),
Ec2MetaHandler)
server.serve_forever()
finally:
os.unlink(pidfile)
......@@ -110,7 +110,8 @@ version.c: tmcd.c
install: all
install: $(INSTALL_SBINDIR)/tmcd \
$(INSTALL_SBINDIR)/tmcd.restart
$(INSTALL_SBINDIR)/tmcd.restart \
$(INSTALL_SBINDIR)/Ec2MetaServer.py
control-install:
boss-install: install
......
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