whiskyechobravo / kerkoapp

A web application that provides a faceted search interface for bibliographies managed with Zotero.
https://whiskyechobravo.github.io/kerko/
BSD 3-Clause "New" or "Revised" License
68 stars 24 forks source link

Windows installation - exceptions about logging thrown #36

Closed simon-20 closed 1 year ago

simon-20 commented 1 year ago

Hi,

I'm attempting to get Kerko and KerkoApp running on Windows 10. I've seen in the previous issues that some people have succeeded with this, with a few tweaks. However I'm running into a problem which I haven't seen mentioned.

Upon running:

flask kerko sync

for the first time, I receive the following error:

'FLASK_ENV' is deprecated and will not be used in Flask 2.3. Use 'FLASK_DEBUG' instead.
Traceback (most recent call last):
  File "C:\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Python310\Scripts\flask.exe\__main__.py", line 7, in <module>
  File "C:\Users\simon\AppData\Roaming\Python\Python310\site-packages\flask\cli.py", line 1047, in main
    cli.main()
  File "C:\Python310\lib\site-packages\click\core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "C:\Python310\lib\site-packages\click\core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Python310\lib\site-packages\click\core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Python310\lib\site-packages\click\core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Python310\lib\site-packages\click\core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "C:\Python310\lib\site-packages\click\decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "**PATH REMOVED**\AppData\Roaming\Python\Python310\site-packages\flask\cli.py", line 354, in decorator
    app = __ctx.ensure_object(ScriptInfo).load_app()
  File "**PATH REMOVED**\AppData\Roaming\Python\Python310\site-packages\flask\cli.py", line 308, in load_app
    app = locate_app(import_name, name)
  File "**PATH REMOVED**\AppData\Roaming\Python\Python310\site-packages\flask\cli.py", line 218, in locate_app
    __import__(module_name)
  File "**PATH REMOVED**\kerko\kerkoapp\kerkoapp.py", line 9, in <module>
    app = create_app(env.str('FLASK_ENV'))
  File "**PATH REMOVED**\kerko\kerkoapp\app\__init__.py", line 25, in create_app
    register_extensions(app)
  File "**PATH REMOVED**\kerko\kerkoapp\app\__init__.py", line 33, in register_extensions
    logging.init_app(app)
  File "**PATH REMOVED**\kerko\kerkoapp\app\logging.py", line 40, in init_app
    syslog_handler = SysLogHandler(app.config.get('LOGGING_ADDRESS', '/dev/log'))
  File "C:\Python310\lib\logging\handlers.py", line 870, in __init__
    self._connect_unixsocket(address)
  File "C:\Python310\lib\logging\handlers.py", line 902, in _connect_unixsocket
    self.socket = socket.socket(socket.AF_UNIX, use_socktype)
AttributeError: module 'socket' has no attribute 'AF_UNIX'
Exception ignored in atexit callback: <function shutdown at 0x000002B3CC46ADD0>
Traceback (most recent call last):
  File "C:\Python310\lib\logging\__init__.py", line 2183, in shutdown
    h.close()
  File "C:\Python310\lib\logging\handlers.py", line 941, in close
    self.socket.close()
AttributeError: 'SysLogHandler' object has no attribute 'socket'

Any help on this would be much appreciated.

Thank you

davidlesieur commented 1 year ago

Hi,

If you are running KerkoApp on a development machine, you might want to set the value of the FLASK_ENV environment variable to development. Otherwise you'll be running on production settings, which attempt to use the syslog logging handler, which won't work on Windows. If you are looking at hosting KerkoApp on Windows for production, then perhaps you could set the value of the LOGGING_HANDLER variable to an empty value (which should cause KerkoApp to use a default handler).

I hope this helps. Please let us know of the results.

KerkoApp's default production settings should probably be changed to avoid this issue on Windows, but hopefully the above workarounds can work in the meantime.

davidlesieur commented 1 year ago

The new configuration system currently in development (#38) should help avoid this kind of trouble in the future. The syslog logging handler will have to be explicitly enabled in a configuration file.

simon-20 commented 1 year ago

Hi,

Thanks for your reply, and help.

I'm not sure it was entirely related to Windows. When attempting to get it set up on PythonAnywhere, I also received exceptions being thrown due to the logging handler, and exceptions thrown during the attempted handling of the logging. But I've been able to resolve some of the issues by setting LOGGING_HANDLER to an empty value, as you suggest.

Many thanks