Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Server

Notices

Reply
 
Thread Tools Search this Thread
Old 04-08-2020, 09:16 PM   #1
AllowPing
Junior Member
AllowPing began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Apr 2020
Device: none
Issues with environment variable CALIBRE_OVERRIDE_DATABASE_PATH on headless Ubuntu

Using a Ubuntu 19.10 install. New to the forum, so please let me know if formatting needs adjusting.

I am able to add books to the library with the below and have verified the db is where I need it, outside of the library directory:
Code:
CALIBRE_OVERRIDE_DATABASE_PATH=/home/a_real_person/calibre-library/db/metadata.db calibredb add /home/a_real_person/calibre-data/test_read/* --library-path /home/a_real_person/calibre-data/test_write
But when running as a /etc/systemd/system/calibre-server.service, an error is returned when checking the service status:
Quote:
There is no calibre library at: /home/a_real_person/calibre-data/test_write
The systemd service is stock, directly from here with edits only for file paths:
https://manual.calibre-ebook.com/ser...n-linux-system

The same error is returned when running as a command:
Code:
CALIBRE_OVERRIDE_DATABASE_PATH=/home/a_real_person/calibre-library/db/metadata.db /opt/calibre/calibre-server /home/a_real_person/calibre-data/test_write
If I move metadata.db to the library directory (test_write) the server runs successfully. Keeping the environment variable prepended to the command has no bearing on it running successfully once the db is in the same directory as the library.

I've tried setting the environment variable in two places:
/etc/environment and ~/.profile

Running printenv returns what I'd expect:
CALIBRE_OVERRIDE_DATABASE_PATH=/home/a_real_person/calibre-library/db/metadata.db

Also tried using this to set the environment variable, but calibre-server doesn't seem to like that:
systemctl edit calibre-server.service

Using the portable version proved to be a bit too complicated for me to use at this point. An official calibre github entry posted a while ago detailed that the portable version locks the files for exclusive app access. This seemed to be the case for me. One may respond saying that you simply need to edit the variable needed and leave the rest 'as is', though the portable version seems to introduce more than my linux skills understand at this point. I'm open to using it again, though I'd prefer to see a simple service work with a custom db directory.
/opt/calibre/resources/calibre-portable.sh

I've also tried setting a custom shell script where the environment variable is defined there, detailed in the below forum thread.

I do see forum threads complaining of the same problem in the Ubuntu/linux OS, though haven't come across one where the OP reports it to start working. Please refer me to one (headless Ubuntu/Debian) if it is known. I've tried the approach offered here, with no success:
https://www.mobileread.com/forums/sh...d.php?t=273420
I don't see the logic in this suggested line:
Code:
cp $CONTENT/metadata.db $CALIBRE_OVERRIDE_DATABASE_PATH
I have come across docker forum threads elsewhere, that reported issues with the db outside of the default location. A couple updated saying they were able to get it working, though details on how to do so were limited.

A VPS is used for this, so it has been pretty quick to wipe the OS and rebuild it to test in-between a few of these attempts.

Help on this would be appreciated.
AllowPing is offline   Reply With Quote
Old 04-08-2020, 10:50 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,345
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
The server is not going to work with that, it serves up multiple libraries. CALIBRE_OVERRIDE_DATABASE_PATH basically limits calibre to using a single library. It *might* work if you specify that single library as a server command line argument but this is not really tested/supported.

What portable version are you talking about. There is no official portable version for linux. Why do you want the db outside the library folders. The original intent for this hack is for when libraries are on slow external media.
kovidgoyal is offline   Reply With Quote
Old 04-10-2020, 11:35 AM   #3
AllowPing
Junior Member
AllowPing began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Apr 2020
Device: none
My use case is 1 library only. In this way, am I correct in assuming it should work?

I had specified portable version above (/opt/calibre/resources/calibre-portable.sh). I was testing running calibre-portable.sh in a systemd service, though I may have not been using it as intended. The script is introduced by saying it supports Linux - this is a copy/paste from that file:
Code:
#                       Calibre-Portable.sh
#                       ¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬
#
# Shell script File to start a Calibre configuration on Linux
# giving explicit control of the location of:
#  - Calibre Program Files
#  - Calibre Library Files
#  - Calibre Config Files
#  - Calibre Metadata database
...
The goal is to use a tested/supported/documented approach to having the db in a different location than the library. I've based my setup on the below:

https://manual.calibre-ebook.com/cus...ment-variables
Quote:
CALIBRE_OVERRIDE_DATABASE_PATH - allows you to specify the full path to metadata.db. Using this variable you can have metadata.db be in a location other than the library folder. Useful if your library folder is on a networked drive that does not support file locking.
AllowPing is offline   Reply With Quote
Old 04-10-2020, 11:48 AM   #4
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,345
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
but why do you want the db in a different location than the library??
kovidgoyal is offline   Reply With Quote
Old 04-10-2020, 07:34 PM   #5
AllowPing
Junior Member
AllowPing began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Apr 2020
Device: none
To benefit from assistance, is it necessary to justify the design decisions I make with my system?

My questions are based on using the app according to the documentation. I wouldn't be asking for help if the app was being used in a way that is known to break it. Knowing why I'm venturing to do it this way seems irrelevant to the questions presented.

If one were to reply saying calibre-server isn't designed to handle this approach, I could decide to stop trying. It seems that there is an opportunity to provide some technical guidance with this approach or to update documentation to reflect these limitations. A positive note, to the former opportunity, would be to have a known thread where this is resolved successfully.
AllowPing is offline   Reply With Quote
Old 04-10-2020, 09:33 PM   #6
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,345
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Quote:
Originally Posted by kovidgoyal View Post
It *might* work if you specify that single library as a server command line argument but this is not really tested/supported.
There you go.
kovidgoyal is offline   Reply With Quote
Old 04-11-2020, 05:05 PM   #7
AllowPing
Junior Member
AllowPing began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Apr 2020
Device: none
Like this?

Quote:
The same error is returned when running as a command:

Code:
CALIBRE_OVERRIDE_DATABASE_PATH=/home/a_real_person/calibre-library/db/metadata.db /opt/calibre/calibre-server /home/a_real_person/calibre-data/test_write
If I move metadata.db to the library directory (test_write) the server runs successfully. Keeping the environment variable prepended to the command has no bearing on it running successfully once the db is in the same directory as the library.
Maybe I'm missing something here.
AllowPing is offline   Reply With Quote
Old 04-12-2020, 01:16 AM   #8
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,345
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Quote:
Originally Posted by AllowPing View Post
Like this?



Maybe I'm missing something here.

Yeah you are missing that this is not tested/supported. You are on your own if you try to do it.
kovidgoyal is offline   Reply With Quote
Old 04-14-2020, 08:41 PM   #9
AllowPing
Junior Member
AllowPing began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Apr 2020
Device: none
My takeaway from this back-and-forth is that not everything in calibre documentation *should* work. Out of the box, I've had a solid experience. My assumption, for any software, is that things in documentation are supported/tested (or at least acknowledged to be unreliable when that's the case).

I chose this software because of what was in documentation - that a db can live outside of the library. The tens of hours spent testing and then reading forums of people having the same problem as myself leaves me knowing that time could have instead been spent implementing something that actually fits the design I'm needing. If I continue to use calibre, it will only be with the default install.
AllowPing is offline   Reply With Quote
Old 12-10-2021, 09:37 AM   #10
ta264
Junior Member
ta264 began at the beginning.
 
Posts: 4
Karma: 10
Join Date: May 2021
Device: Kindle Oasis
I just ran into the same thing.

I'm running calibre-server on a headless linux server in docker. Ideally I'd have the metadata.db on the SSD and only the books on the HDD.
ta264 is offline   Reply With Quote
Old 03-05-2022, 01:51 AM   #11
AllowPing
Junior Member
AllowPing began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Apr 2020
Device: none
Using the below compliments calibre very well. I edit all content only in calibre, then copy it off to another system, using the docker container calibre-web, which is purpose-built to be web-facing and light:
https://docs.linuxserver.io/images/docker-calibre-web
AllowPing is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting environment variable dator Server 2 09-08-2018 08:57 AM
Environment variable for libraries? Stevex Calibre 21 03-14-2017 12:05 PM
headless ebook-convert running on Ubuntu for Windows wooverine Devices 2 05-02-2016 10:25 PM
Ubuntu Headless, Windows 8.1 and database malformation (Cygwin?) Kouwezakkie Devices 2 03-01-2015 01:56 PM
CALIBRE_CONFIG_DIRECTORY Environment variable huotg01 Calibre 15 11-14-2013 12:09 PM


All times are GMT -4. The time now is 04:07 PM.


MobileRead.com is a privately owned, operated and funded community.