View Single Post
Old 09-22-2011, 08:54 PM   #1
adamaymas
Junior Member
adamaymas doesn't litteradamaymas doesn't litter
 
Posts: 5
Karma: 108
Join Date: Sep 2011
Device: SONY PRS-350
difficulties getting calibre-server to work with apache/wsgi

I am trying to run calibre-server running behind apache using the wsgi module.

I'm running calibre 0.8.19 on a gentoo x86_64 system, compiled from source.

I've followed the instructions online but when I try to load the calibre homepage I get:

Code:
500 Internal Server Error

The server encountered an unexpected condition which prevented it from fulfilling the request.

Traceback (most recent call last):
  File "/usr/lib/calibre/cherrypy/_cprequest.py", line 587, in respond
    self.get_resource(path_info)
  File "/usr/lib/calibre/cherrypy/_cprequest.py", line 691, in get_resource
    dispatch(path)
  File "/usr/lib/calibre/cherrypy/_cpdispatch.py", line 367, in __call__
    func = self.find_handler(path_info)
  File "/usr/lib/calibre/cherrypy/_cpdispatch.py", line 382, in find_handler
    config.environ = cherrypy.request.wsgi_environ
  File "/usr/lib/calibre/routes/__init__.py", line 22, in __setattr__
    self.load_wsgi_environ(value)
  File "/usr/lib/calibre/routes/__init__.py", line 51, in load_wsgi_environ
    result = mapper.routematch(path)
  File "/usr/lib/calibre/routes/mapper.py", line 686, in routematch
    raise RoutesException('URL or environ must be provided')
RoutesException: URL or environ must be provided
So Apache is getting as far as attempting to run the calibre server but something's wrong and I know too little python...

Here is the apache error log after starting and attempting to load the calibre home page:

Code:
[Thu Sep 22 17:27:44 2011] [notice] mod_python: Creating 8 session mutexes based on 150 max processes and 0 max threads.
[Thu Sep 22 17:27:44 2011] [notice] mod_python: using mutex_directory /tmp 
[Thu Sep 22 17:27:44 2011] [notice] Apache/2.2.21 (Unix) mod_ssl/2.2.21 OpenSSL/1.0.0e mod_python/3.3.1 Python/2.7.1 mod_wsgi/3.3 configured -- resuming normal operations
Nothing in the error log after this so Apache seems to be working fine.

Here is my wsgi script:
Code:
# CALIBRE_RESOURCES_PATH
sys.resources_location = '/usr/share/calibre'

# CALIBRE_EXTENSIONS_PATH
sys.extensions_location = '/usr/lib/calibre/calibre/plugins'

# Path to directory containing calibre executables
sys.executables_location = '/usr/bin'

# Path to a directory for which the server has read/write permissions
# calibre config will be stored here
os.environ['CALIBRE_CONFIG_DIRECTORY'] = '/var/www/localhost/calibre-config'

del sys
del os

from calibre.library.server.main import create_wsgi_app
application = create_wsgi_app(
        # The mount point of this WSGI application (i.e. the first argument to
        # the WSGIScriptAlias directive). Set to empty string is mounted at /
        prefix='/calibre',

        # Path to the calibre library to be served
        # The server process must have write permission for all files/dirs
        # in this directory or BAD things will happen
        path_to_library='/data/Calibre/Calibre-main'
)

del create_wsgi_app
I get the same problem when trying to do it with a gentoo ebuild which is at calibre 0.8.18. Maybe I'm just missing some hidden dependency (but it compiles without errors or warnings) but I just can't figure it out.

BTW, I have no problems running the calibre server using the calibre-server command and I also have no problems reverse proxying using apache. So this is far from being a deal-breaker for me but I'd love to have just one web server running on my server at home.
adamaymas is offline   Reply With Quote