thirdparty/google_appengine/google/appengine/tools/dev_appserver_main.py
changeset 2864 2e0b0af889be
parent 2413 d0b7dac5325c
equal deleted inserted replaced
2862:27971a13089f 2864:2e0b0af889be
    66 
    66 
    67 import getopt
    67 import getopt
    68 import logging
    68 import logging
    69 import os
    69 import os
    70 import re
    70 import re
       
    71 import signal
    71 import sys
    72 import sys
    72 import traceback
    73 import traceback
    73 import tempfile
    74 import tempfile
       
    75 
       
    76 logging.basicConfig(
       
    77     level=logging.INFO,
       
    78     format='%(levelname)-8s %(asctime)s %(filename)s:%(lineno)s] %(message)s')
    74 
    79 
    75 
    80 
    76 def SetGlobals():
    81 def SetGlobals():
    77   """Set various global variables involving the 'google' package.
    82   """Set various global variables involving the 'google' package.
    78 
    83 
   377       host_override=option_dict[ARG_ADMIN_CONSOLE_HOST])
   382       host_override=option_dict[ARG_ADMIN_CONSOLE_HOST])
   378   server.authenticated = True
   383   server.authenticated = True
   379   return server
   384   return server
   380 
   385 
   381 
   386 
       
   387 def SigTermHandler(signum, frame):
       
   388   """Handler for TERM signal.
       
   389 
       
   390   Raises a KeyboardInterrupt to perform a graceful shutdown on SIGTERM signal.
       
   391   """
       
   392   raise KeyboardInterrupt()
       
   393 
       
   394 
   382 def main(argv):
   395 def main(argv):
   383   """Runs the development application server."""
   396   """Runs the development application server."""
   384   args, option_dict = ParseArguments(argv)
   397   args, option_dict = ParseArguments(argv)
   385 
   398 
   386   if len(args) != 1:
   399   if len(args) != 1:
   417   allow_skipped_files = option_dict[ARG_ALLOW_SKIPPED_FILES]
   430   allow_skipped_files = option_dict[ARG_ALLOW_SKIPPED_FILES]
   418   static_caching = option_dict[ARG_STATIC_CACHING]
   431   static_caching = option_dict[ARG_STATIC_CACHING]
   419 
   432 
   420   option_dict['root_path'] = os.path.realpath(root_path)
   433   option_dict['root_path'] = os.path.realpath(root_path)
   421 
   434 
   422   logging.basicConfig(
   435   logging.getLogger().setLevel(log_level)
   423     level=log_level,
       
   424     format='%(levelname)-8s %(asctime)s %(filename)s:%(lineno)s] %(message)s')
       
   425 
   436 
   426   config = None
   437   config = None
   427   try:
   438   try:
   428     config, matcher = dev_appserver.LoadAppConfig(root_path, {})
   439     config, matcher = dev_appserver.LoadAppConfig(root_path, {})
   429   except yaml_errors.EventListenerError, e:
   440   except yaml_errors.EventListenerError, e:
   458       sdk_dir=SDK_PATH,
   469       sdk_dir=SDK_PATH,
   459       serve_address=serve_address,
   470       serve_address=serve_address,
   460       require_indexes=require_indexes,
   471       require_indexes=require_indexes,
   461       allow_skipped_files=allow_skipped_files,
   472       allow_skipped_files=allow_skipped_files,
   462       static_caching=static_caching)
   473       static_caching=static_caching)
       
   474 
       
   475   signal.signal(signal.SIGTERM, SigTermHandler)
   463 
   476 
   464   logging.info('Running application %s on port %d: http://%s:%d',
   477   logging.info('Running application %s on port %d: http://%s:%d',
   465                config.application, port, serve_address, port)
   478                config.application, port, serve_address, port)
   466   try:
   479   try:
   467     try:
   480     try: