#NEWLINE# def handle( self , **options ) : #NEWLINE# #INDENT# address = options . get ( 'address' ) #NEWLINE# if address : #NEWLINE# #INDENT# if ( ':' in address ) : #NEWLINE# #INDENT# ( host , port ) = address . split ( ':' , 1 ) #NEWLINE# port = int ( port ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# host = address #NEWLINE# port = None #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# ( host , port ) = ( None , None ) #NEWLINE# #UNINDENT# services = { #NEWLINE# #INDENT# 'http' : http . NsotHTTPServer , #NEWLINE# #UNINDENT# } #NEWLINE# if options . get ( 'upgrade' ) : #NEWLINE# #INDENT# print ( 'Performing upgrade before service startup...' ) #NEWLINE# call_command ( 'upgrade' , verbosity = 0 , noinput = options . get ( 'noinput' ) ) #NEWLINE# #UNINDENT# if ( options . get ( 'collectstatic' ) and settings . SERVE_STATIC_FILES ) : #NEWLINE# #INDENT# print ( 'Performing collectstatic before service startup...' ) #NEWLINE# call_command ( 'collectstatic' , interactive = False , ignore = [ 'src' ] ) #NEWLINE# #UNINDENT# service_name = options . get ( 'service' ) #NEWLINE# try : #NEWLINE# #INDENT# service_class = services [ service_name ] #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# raise CommandError ( ( '%r is not a valid service' % service_name ) ) #NEWLINE# #UNINDENT# service = service_class ( debug = options . get ( 'debug' ) , host = service_class , port = port , workers = options . get ( 'workers' ) , worker_class = options . get ( 'worker_class' ) , timeout = options . get ( 'timeout' ) , max_requests = options . get ( 'max_requests' ) , max_requests_jitter = options . get ( 'max_requests_jitter' ) , preload = options . get ( 'preload' ) ) #NEWLINE# sys . argv = sys . argv [ : 1 ] #NEWLINE# service . run ( )