X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=geni%2Fplc.py;h=8565fee94caaaa54ca067cc78eebe50b557c0b96;hb=c9c6424304e5e73d4bd846b09b451e5f3d5f508d;hp=a1157907c415a5ee94a8e0edaa78a736f08f2eec;hpb=1d53363bdbaecfeefc63275c268dd60ea3167fcf;p=sfa.git diff --git a/geni/plc.py b/geni/plc.py index a1157907..8565fee9 100644 --- a/geni/plc.py +++ b/geni/plc.py @@ -1,3 +1,4 @@ +#!/usr/bin/python ## # GENI PLC Wrapper # @@ -40,6 +41,21 @@ from geni.registry import Registry from geni.aggregate import Aggregate from geni.slicemgr import SliceMgr + +# after http://www.erlenstar.demon.co.uk/unix/faq_2.html +def daemon(): + """Daemonize the current process.""" + if os.fork() != 0: os._exit(0) + os.setsid() + if os.fork() != 0: os._exit(0) + os.umask(0) + devnull = os.open(os.devnull, os.O_RDWR) + os.dup2(devnull, 0) + # xxx fixme - this is just to make sure that nothing gets stupidly lost - should use devnull + crashlog = os.open('/var/log/geni.daemon', os.O_RDWR | os.O_APPEND | os.O_CREAT, 0644) + os.dup2(crashlog, 1) + os.dup2(crashlog, 2) + def main(): global AuthHierarchy global TrustedRoots @@ -57,10 +73,14 @@ def main(): help="run aggregate manager", default=False) parser.add_option("-v", "--verbose", dest="verbose", action="store_true", help="verbose mode", default=False) + parser.add_option("-d", "--daemon", dest="daemon", action="store_true", + help="Run as daemon.", default=False) (options, args) = parser.parse_args() key_file = "server.key" cert_file = "server.cert" + + if (options.daemon): daemon() if (os.path.exists(key_file)) and (not os.path.exists(cert_file)): # If private key exists and cert doesnt, recreate cert @@ -88,20 +108,20 @@ def main(): # start registry server if (options.registry): r = Registry("", registry_port, key_file, cert_file) - r.trusted_cert_list = TrustedRoots.get_list() - r.hierarchy = AuthHierarchy + #r.trusted_cert_list = TrustedRoots.get_list() + #r.hierarchy = AuthHierarchy r.start() # start aggregate manager if (options.am): a = Aggregate("", aggregate_port, key_file, cert_file) - a.trusted_cert_list = TrustedRoots.get_list() + #a.trusted_cert_list = TrustedRoots.get_list() a.start() # start slice manager if (options.sm): s = SliceMgr("", slicemgr_port, key_file, cert_file) - s.trusted_cert_list = TrustedRoots.get_list() + #s.trusted_cert_list = TrustedRoots.get_list() s.start() if __name__ == "__main__":