Skip to content

Commit

Permalink
fuxes #282
Browse files Browse the repository at this point in the history
  • Loading branch information
advornic committed Jan 28, 2015
1 parent 984dbd3 commit d94a8fb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
11 changes: 4 additions & 7 deletions conf/ztpserver.wsgi
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,8 @@ import sys

from ztpserver.app import start_wsgiapp

conf = '/etc/ztpserver/ztpserver.conf'
sys.stdout.write('Starting ZTPServer...')

sys.stdout.write('Starting ZTPServer, ')
sys.stdout.write('using config file %s' % conf)

application = start_wsgiapp(conf)
# For debug output, use:
# application = start_wsgiapp(conf, debug=True)
application = start_wsgiapp()
# To enable debug output, use:
# application = start_wsgiapp(debug=True)
9 changes: 8 additions & 1 deletion ztpserver/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,21 +82,27 @@ def python_supported():
""" Returns True if the current version of the python runtime is valid """
return sys.version_info > (2, 7) and sys.version_info < (3, 0)

logging_started = False
def start_logging(debug):
""" reads the runtime config and starts logging if enabled """
if logging_started:
return

if config.runtime.default.logging:
if config.runtime.default.console_logging:
enable_handler_console('DEBUG' if debug else 'INFO')

global logging_started
logging_started = True

def load_config(conf=None):
conf = conf or DEFAULT_CONF
conf = os.environ.get('ZTPS_CONFIG', conf)

if os.path.exists(conf):
config.runtime.read(conf)

def start_wsgiapp():
def start_wsgiapp(debug=False):
""" Provides the entry point into the application for wsgi compliant
servers. Accepts a single keyword argument ``conf``. The ``conf``
keyword argument specifies the path the server configuration file. The
Expand All @@ -107,6 +113,7 @@ def start_wsgiapp():
"""

start_logging(debug)
log.info('Logging started for ztpserver')
log.info('Using repository %s', config.runtime.default.data_root)

Expand Down

0 comments on commit d94a8fb

Please sign in to comment.