我们从Python开源项目中,提取了以下2个代码示例,用于说明如何使用cherrypy.process()。
def run(): from optparse import OptionParser p = OptionParser() p.add_option('-c', '--config', action='append', dest='config', help='specify config file(s)') p.add_option('-d', action='store_true', dest='daemonize', help='run the server as a daemon') p.add_option('-e', '--environment', dest='environment', default=None, help='apply the given config environment') p.add_option('-f', action='store_true', dest='fastcgi', help='start a fastcgi server instead of the default HTTP ' 'server') p.add_option('-s', action='store_true', dest='scgi', help='start a scgi server instead of the default HTTP server') p.add_option('-x', action='store_true', dest='cgi', help='start a cgi server instead of the default HTTP server') p.add_option('-i', '--import', action='append', dest='imports', help='specify modules to import') p.add_option('-p', '--pidfile', dest='pidfile', default=None, help='store the process id in the given file') p.add_option('-P', '--Path', action='append', dest='Path', help='add the given paths to sys.path') options, args = p.parse_args() if options.Path: for p in options.Path: sys.path.insert(0, p) start(options.config, options.daemonize, options.environment, options.fastcgi, options.scgi, options.pidfile, options.imports, options.cgi)
def run(): from optparse import OptionParser p = OptionParser() p.add_option('-c', '--config', action="append", dest='config', help="specify config file(s)") p.add_option('-d', action="store_true", dest='daemonize', help="run the server as a daemon") p.add_option('-e', '--environment', dest='environment', default=None, help="apply the given config environment") p.add_option('-f', action="store_true", dest='fastcgi', help="start a fastcgi server instead of the default HTTP " "server") p.add_option('-s', action="store_true", dest='scgi', help="start a scgi server instead of the default HTTP server") p.add_option('-x', action="store_true", dest='cgi', help="start a cgi server instead of the default HTTP server") p.add_option('-i', '--import', action="append", dest='imports', help="specify modules to import") p.add_option('-p', '--pidfile', dest='pidfile', default=None, help="store the process id in the given file") p.add_option('-P', '--Path', action="append", dest='Path', help="add the given paths to sys.path") options, args = p.parse_args() if options.Path: for p in options.Path: sys.path.insert(0, p) start(options.config, options.daemonize, options.environment, options.fastcgi, options.scgi, options.pidfile, options.imports, options.cgi)