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 01-06-2020, 08:40 PM   #1
davidreads
Junior Member
davidreads began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Jan 2020
Device: none
Calibre-server systemd socket unit example

The calibre documentation mentions that it supports socket activation. Does anyone have a working socket unit and service unit pair that will start the server on first connection then stop the server after some timeout? Thanks in advance.

David
davidreads is offline   Reply With Quote
Old 01-10-2020, 04:38 PM   #2
davidreads
Junior Member
davidreads began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Jan 2020
Device: none
[SOLUTION] socket unit example

Answering my own question for future readers.

I created the following systemd unit files:

calibre-server@.socket:
Code:
[Unit]
Description=Calibre Server socket

[Socket]
ListenStream=33154

[Install]
WantedBy=sockets.target
calibre-server@.service
Code:
[Unit]
Description=Calibre content server
After=network.target

[Service]
Type=simple
User=%i
Group=%i
ExecStart=/usr/bin/calibre-server --enable-allow-socket-preallocation "/home/%i/Media/Books/Calibre Library"
RuntimeMaxSec=300
Restart=no

[Install]
WantedBy=multi-user.target
I can then start them with:
Code:
systemctl start calibre-server@user1.socket
This will start the socket service for user1 to listen for connections. On connection, it will run calibre-server as user1 and serve the books out of that users's calibre library. The instance of calibre-server will stop after 5 minutes to minimize use of system resources but will start again on the next connection.

I can also add another socket unit named calibre-server@user2.socket with a different ListenStream to serve user2's library on a different port.

Last edited by davidreads; 01-10-2020 at 04:40 PM.
davidreads is offline   Reply With Quote
Advert
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Calibre3 systemd jrp13149 Devices 2 11-01-2017 12:36 PM
--Manage-users and systemd dom134 Calibre 6 06-30-2017 04:37 PM
Calibre Companion connecting unit / computer jayp2013mobile Calibre Companion 23 03-03-2016 02:07 PM
Calibre has no choice on font size unit in css? naisren ePub 6 09-30-2012 09:41 AM
500 Internal Server Error accessing content server Calibre 0.8.8 DaddyO57 Calibre 1 07-20-2012 06:08 PM


All times are GMT -4. The time now is 05:40 PM.


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