Esempio n. 1
0
def main():
    """Initializes the server."""

    op = optparse.OptionParser(description=DESCRIPTION, usage=USAGE)

    op.add_option("--log", dest="logfile", metavar="FILE",
                  help="write logging output to this file",
                  default=os.path.join(os.environ['TMPDIR'], 'fcgi.log'))

    (options, args) = op.parse_args()

    if sys.argv[-1].startswith('-') or sys.argv[-1] == sys.argv[0]:
        op.print_usage()
        sys.exit(2)

    app_root = sys.argv[-1]

    logging.basicConfig(
        format='%(levelname)-8s %(asctime)s %(filename)s:%(lineno)s] '
               '%(message)s',
        level=logging.INFO, filename=options.logfile)

    # Change the current working directory to the application root and load
    # the application configuration
    os.chdir(app_root)
    sys.path.insert(0, app_root)
    conf = twistedae.getAppConfig()

    # Inititalize API proxy stubs
    twistedae.setupStubs(conf)

    # Serve the application
    try:
        serve(conf)
    except:
        logging.error(get_traceback())
Esempio n. 2
0
    def testSetupStubs(self):
        """Sets up apiproxy stubs."""

        twistedae.setupStubs(self.conf)