Run cherryd CLI.
()
| 73 | |
| 74 | |
| 75 | def run(): |
| 76 | """Run cherryd CLI.""" |
| 77 | from optparse import OptionParser |
| 78 | |
| 79 | p = OptionParser() |
| 80 | p.add_option('-c', '--config', action='append', dest='config', |
| 81 | help='specify config file(s)') |
| 82 | p.add_option('-d', action='store_true', dest='daemonize', |
| 83 | help='run the server as a daemon') |
| 84 | p.add_option('-e', '--environment', dest='environment', default=None, |
| 85 | help='apply the given config environment') |
| 86 | p.add_option('-f', action='store_true', dest='fastcgi', |
| 87 | help='start a fastcgi server instead of the default HTTP ' |
| 88 | 'server') |
| 89 | p.add_option('-s', action='store_true', dest='scgi', |
| 90 | help='start a scgi server instead of the default HTTP server') |
| 91 | p.add_option('-x', action='store_true', dest='cgi', |
| 92 | help='start a cgi server instead of the default HTTP server') |
| 93 | p.add_option('-i', '--import', action='append', dest='imports', |
| 94 | help='specify modules to import') |
| 95 | p.add_option('-p', '--pidfile', dest='pidfile', default=None, |
| 96 | help='store the process id in the given file') |
| 97 | p.add_option('-P', '--Path', action='append', dest='Path', |
| 98 | help='add the given paths to sys.path') |
| 99 | options, args = p.parse_args() |
| 100 | |
| 101 | if options.Path: |
| 102 | for p in options.Path: |
| 103 | sys.path.insert(0, p) |
| 104 | |
| 105 | start(options.config, options.daemonize, |
| 106 | options.environment, options.fastcgi, options.scgi, |
| 107 | options.pidfile, options.imports, options.cgi) |