1
0
mirror of https://github.com/webrecorder/pywb.git synced 2025-03-15 00:03:28 +01:00

setup: add cli scripts for wayback, cdx-server

fix logging of app name, make most logging debug
This commit is contained in:
Ilya Kreymer 2014-03-08 15:09:53 -08:00
parent 40b7a8e921
commit 541c076b77
4 changed files with 18 additions and 7 deletions

View File

@ -13,5 +13,8 @@ application = init_app(create_cdx_server_app,
load_yaml=True, load_yaml=True,
config_file=DEFAULT_CONFIG) config_file=DEFAULT_CONFIG)
def main():
start_wsgi_server(application, 'CDX Server')
if __name__ == "__main__": if __name__ == "__main__":
start_wsgi_server(application) main()

View File

@ -6,5 +6,8 @@ from pywb.core.pywb_init import create_wb_router
#================================================================= #=================================================================
application = init_app(create_wb_router, load_yaml=True) application = init_app(create_wb_router, load_yaml=True)
def main():
start_wsgi_server(application, 'Wayback')
if __name__ == "__main__": if __name__ == "__main__":
start_wsgi_server(application) main()

View File

@ -114,7 +114,7 @@ DEFAULT_CONFIG_FILE = 'config.yaml'
def init_app(init_func, load_yaml=True, config_file=None): def init_app(init_func, load_yaml=True, config_file=None):
logging.basicConfig(format='%(asctime)s: [%(levelname)s]: %(message)s', logging.basicConfig(format='%(asctime)s: [%(levelname)s]: %(message)s',
level=logging.DEBUG) level=logging.DEBUG)
logging.info('') logging.debug('')
if load_yaml: if load_yaml:
if not config_file: if not config_file:
@ -135,13 +135,13 @@ def init_app(init_func, load_yaml=True, config_file=None):
raise raise
else: else:
msg = '*** pywb app inited with config from "%s"!\n' msg = '*** pywb app inited with config from "%s"!\n'
logging.info(msg, init_func.__name__) logging.debug(msg, init_func.__name__)
return WSGIApp(wb_router) return WSGIApp(wb_router)
#================================================================= #=================================================================
def start_wsgi_server(the_app): # pragma: no cover def start_wsgi_server(the_app, name): # pragma: no cover
from wsgiref.simple_server import make_server from wsgiref.simple_server import make_server
from optparse import OptionParser from optparse import OptionParser
@ -158,7 +158,7 @@ def start_wsgi_server(the_app): # pragma: no cover
if not port: if not port:
port = DEFAULT_PORT port = DEFAULT_PORT
logging.debug('Starting CDX Server on port %s', port) logging.info('Starting %s on port %s', name, port)
try: try:
httpd = make_server('', port, the_app) httpd = make_server('', port, the_app)
@ -166,4 +166,4 @@ def start_wsgi_server(the_app): # pragma: no cover
except KeyboardInterrupt as ex: except KeyboardInterrupt as ex:
pass pass
finally: finally:
logging.debug('Stopping CDX Server') logging.info('Stopping %s', name)

View File

@ -76,4 +76,9 @@ setup(
], ],
cmdclass={'test': PyTest}, cmdclass={'test': PyTest},
test_suite='', test_suite='',
entry_points="""
[console_scripts]
wayback = pywb.apps.wayback:main
cdx-server = pywb.apps.cdx_server:main
"""
) )