def start_server_servestatic(options): """ Start CherryPy server AND serve default static files Want SSL support? a. The new (3.1 or 3.2) way: Just set server.ssl_adapter to an SSLAdapter instance. b. The old way (deprecated way) is to set these attributes: server.ssl_certificate = <filename> server.ssl_private_key = <filename> But this is the only way from the management command line in the future I may need to adapt this to use a server.ssl_adapter """ if options['daemonize'] and options['server_user'] and options['server_group']: #ensure the that the daemon runs as specified user change_uid_gid(options['server_user'], options['server_group']) from django_wsgiserver.wsgiserver import CherryPyWSGIServer, WSGIPathInfoDispatcher #from cherrypy.wsgiserver import CherryPyWSGIServer, WSGIPathInfoDispatcher from django.core.handlers.wsgi import WSGIHandler from django.conf import settings app = WSGIHandler() if options['adminserve']: # serve the admin media too # AdminMediaHandler is middleware for local use import django.core.servers.basehttp app = django.core.servers.basehttp.AdminMediaHandler(app) # another way to serve the admin media three application path = { '/': app, settings.MEDIA_URL: mediahandler.MediaHandler(settings.MEDIA_ROOT), settings.STATIC_URL + "admin/": mediahandler.MediaHandler( os.path.join( django.contrib.admin.__path__[0], 'static/admin' ) ) } dispatcher = WSGIPathInfoDispatcher( path ) server = CherryPyWSGIServer( (options['host'], int(options['port'])), dispatcher, int(options['threads']), options['server_name'] ) if options['ssl_certificate'] and options['ssl_private_key']: server.ssl_certificate = options['ssl_certificate'] server.ssl_private_key = options['ssl_private_key'] try: server.start() except KeyboardInterrupt: server.stop()
def start_server(options): """ Start CherryPy server Want SSL support? a. The new (3.1 or 3.2) way: Just set server.ssl_adapter to an SSLAdapter instance. b. The old way (deprecated way) is to set these attributes: server.ssl_certificate = <filename> server.ssl_private_key = <filename> But this is the only way from the management command line in the future I may need to adapt this to use a server.ssl_adapter """ if options['daemonize'] and options['server_user'] and options['server_group']: #ensure the that the daemon runs as specified user change_uid_gid(options['server_user'], options['server_group']) from django_wsgiserver.wsgiserver import CherryPyWSGIServer #from cherrypy.wsgiserver import CherryPyWSGIServer from django.core.handlers.wsgi import WSGIHandler app = WSGIHandler() if options['adminserve']: # serve the admin media too # AdminMediaHandler is middleware for local use import django.core.servers.basehttp app = django.core.servers.basehttp.AdminMediaHandler(app) server = CherryPyWSGIServer( (options['host'], int(options['port'])), app, int(options['threads']), options['server_name'] ) if options['ssl_certificate'] and options['ssl_private_key']: server.ssl_certificate = options['ssl_certificate'] server.ssl_private_key = options['ssl_private_key'] try: server.start() except KeyboardInterrupt: server.stop()
def start_server(options): """ Start CherryPy server Want SSL support? a. The new (3.1 or 3.2) way: Just set server.ssl_adapter to an SSLAdapter instance. b. The old way (deprecated way) is to set these attributes: server.ssl_certificate = <filename> server.ssl_private_key = <filename> But this is the only way from the management command line in the future I may need to adapt this to use a server.ssl_adapter """ if options['daemonize'] and options['server_user'] and options[ 'server_group']: #ensure the that the daemon runs as specified user change_uid_gid(options['server_user'], options['server_group']) from django_wsgiserver.wsgiserver import CherryPyWSGIServer #from cherrypy.wsgiserver import CherryPyWSGIServer from django.core.handlers.wsgi import WSGIHandler app = WSGIHandler() # if options['adminserve']: # serve the admin media too # # AdminMediaHandler is middleware for local use # import django.core.servers.basehttp # app = django.core.servers.basehttp.AdminMediaHandler(app) server = CherryPyWSGIServer((options['host'], int(options['port'])), app, int(options['threads']), options['server_name']) if options['ssl_certificate'] and options['ssl_private_key']: server.ssl_certificate = options['ssl_certificate'] server.ssl_private_key = options['ssl_private_key'] try: logging.debug('starting server with options:\n%s' % pformat(options)) server.start() except KeyboardInterrupt: server.stop()