def main(argv): """ Start things up. """ sys.excepthook = excepthook if len(sys.argv) > 1 and sys.argv[1] == "--list-modules": module_names = module_loader.load_modules().keys() module_names.sort() print "loaded modules:" for foo in module_names: print "\t" + foo sys.exit(0) if "--version" in sys.argv or "-v" in sys.argv: print >> sys.stderr, file("/etc/func/version").read().strip() sys.exit(0) if "daemon" in sys.argv or "--daemon" in sys.argv: utils.daemonize("/var/run/funcd.pid") else: print "serving...\n" try: hn = futils.get_hostname_by_route() requester.request_cert(hn) serve() except codes.FuncException, e: print >> sys.stderr, 'error: %s' % e sys.exit(1)
def main(argv): """ Start things up. """ conf_dir = sys.exec_prefix sys.excepthook = excepthook if len(sys.argv) > 1 and sys.argv[1] == "--list-modules": config = read_config("%s/etc/func/minion.conf" % conf_dir, FuncdConfig) module_names = module_loader.load_modules(module_list = config.module_list).keys() module_names.sort() print "loaded modules:" for foo in module_names: print "\t" + foo sys.exit(0) if "--version" in sys.argv or "-v" in sys.argv: print >> sys.stderr, file("%s/etc/func/version" % conf_dir).read().strip() sys.exit(0) if "--info" in sys.argv: server = setup_server() print 'config:' for l in str(server.config).split('\n'): print '\t' + l print 'server name: %s' % server.server_name print 'server listen addr: %s:%s' % server.server_address print 'key file: %s' % server.key print 'cert file: %s' % server.cert print 'ca file: %s' % server.ca cert = certs.retrieve_cert_from_file(server.cert) print 'cert dn: %s' % cert.get_subject().CN print 'certificate hash: %s' % cert.subject_name_hash() print 'modules loaded:' for mn in sorted(server.modules.keys()): print '\t' + mn print 'acls:' for (host, methods) in server.acls.acls.items(): print '\t' + host + ' : ' + str(methods) print 'facts:' for (n, meth) in server.fact_methods.items(): print '\t' + n + ' : ' + meth() sys.exit(0) if "daemon" in sys.argv or "--daemon" in sys.argv: utils.daemonize("%s/var/run/funcd.pid" % conf_dir) else: print "serving...\n" try: config = read_config("%s/etc/func/minion.conf" % conf_dir, FuncdConfig) if config.use_certmaster: hn = func_utils.get_hostname_by_route() requester.request_cert(hn) serve() except codes.FuncException, e: print >> sys.stderr, 'error: %s' % e sys.exit(1)
def main(argv): """ Start things up. """ sys.excepthook = excepthook if len(sys.argv) > 1 and sys.argv[1] == "--list-modules": config = read_config("/etc/func/minion.conf", FuncdConfig) module_names = module_loader.load_modules( module_list=config.module_list).keys() module_names.sort() print "loaded modules:" for foo in module_names: print "\t" + foo sys.exit(0) if "--version" in sys.argv or "-v" in sys.argv: print >> sys.stderr, file("/etc/func/version").read().strip() sys.exit(0) if "--info" in sys.argv: server = setup_server() print 'config:' for l in str(server.config).split('\n'): print '\t' + l print 'server name: %s' % server.server_name print 'server listen addr: %s:%s' % server.server_address print 'key file: %s' % server.key print 'cert file: %s' % server.cert print 'ca file: %s' % server.ca cert = certs.retrieve_cert_from_file(server.cert) print 'cert dn: %s' % cert.get_subject().CN print 'certificate hash: %s' % cert.subject_name_hash() print 'modules loaded:' for mn in sorted(server.modules.keys()): print '\t' + mn print 'acls:' for (host, methods) in server.acls.acls.items(): print '\t' + host + ' : ' + str(methods) print 'facts:' for (n, meth) in server.fact_methods.items(): print '\t' + n + ' : ' + meth() sys.exit(0) if "daemon" in sys.argv or "--daemon" in sys.argv: utils.daemonize("/var/run/funcd.pid") else: print "serving...\n" try: config = read_config("/etc/func/minion.conf", FuncdConfig) if config.use_certmaster: hn = func_utils.get_hostname_by_route() requester.request_cert(hn) serve() except codes.FuncException, e: print >> sys.stderr, 'error: %s' % e sys.exit(1)
def main(argv): """ Start things up. """ if "daemon" in sys.argv or "--daemon" in sys.argv: utils.daemonize("/var/run/funcd.pid") else: print "serving...\n" try: requester.request_cert() serve() except codes.FuncException, e: print >> sys.stderr, 'error: %s' % e sys.exit(1)
def start(): """Start the CherryPy application server.""" global PRODUCTION_ENV setupdir = dirname(dirname(__file__)) curdir = os.getcwd() # First look on the command line for a desired config file, # if it's not on the command line, then look for 'setup.py' # in the current directory. If there, load configuration # from a file called 'dev.cfg'. If it's not there, the project # is probably installed and we'll look first for a file called # 'prod.cfg' in the current directory and then for a default # config file called 'default.cfg' packaged in the egg. if exists("/etc/funcweb/prod.cfg"): #we work with production settings now ! PRODUCTION_ENV = True configfile = "/etc/funcweb/prod.cfg" elif len(sys.argv) > 1: configfile = sys.argv[1] elif exists(join(setupdir, "setup.py")): configfile = join(setupdir, "dev.cfg") elif exists(join(curdir, "prod.cfg")): configfile = join(curdir, "prod.cfg") else: try: configfile = pkg_resources.resource_filename( pkg_resources.Requirement.parse("funcweb"), "config/default.cfg") except pkg_resources.DistributionNotFound: raise ConfigurationError("Could not find default configuration.") turbogears.update_config(configfile=configfile, modulename="funcweb.config") from funcweb.controllers import Root if PRODUCTION_ENV: utils.daemonize("/var/run/funcwebd.pid") #then start the server try: turbogears.start_server(Root()) except Exception,e: print "Debug information from cherrypy server ...: ",e