View Single Post
Old 11-06-2016, 11:13 AM   #36
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,422
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Well, it will kill the server, yes. `killall` as root is good at that.
And your calibre@matt.service does not specify restarting on failure (or any kind of restarting at all), so it won't restart before the upgrade completes, in fact, you will have to restart it yourself.

Note that the only real reason to kill all calibre processes during an upgrade is to restart them with the new version of calibre, since Linux is perfectly capable of replacing the program files while it is still running.

...

I would try using the "Conflicts=" directive in your calibre-server service, to get it to stop when the upgrade service is running. (I haven't thought about this situation before. I haven't tested it and I am not sure how to make sure it restarts as well. I don't know whether the "Restart=always" directive would restart it when the Conflicting service ends.)

..

Aside: I use the following systemd template service to start the server.

Code:
[eschwartz@arch ~/git/calibre-installer]$  cat ~/.config/systemd/user/calibre-server@.service
[Unit]
Description=Main calibre server
After=network.target

[Service]
EnvironmentFile=/%h/.config/calibre/servers/%i.conf
ExecStart=/usr/bin/calibre-server \
    --port="${port}" \
    --with-library "${path}" \
    --restriction "${restriction}" \
    --user "${user}" \
    --pass "${pass}"

[Install]
WantedBy=default.target
It is run as a user service.

Note that calibre-server does not need to be `--daemonize`d. pidfile+daemonize was necessary for earlier init systems which unlike systemd didn't natively know how to track the lifetime of the executable.

Also note my use of EnvironmentFile to easily template different servers.

In ~/.config/calibre/servers/${server}.conf you can drop values for:

Code:
port=""
path=""
restriction=""
user=""
pass=""
eschwartz is offline   Reply With Quote