Thought it might be worth mentioning for starting seafile at boottime with systemctl/systemd when using an external USB drive. Not mentioned in the manual

Was now digging around for many hours and finaly was able to fix it:

I am using seafile CE on my raspbery pi 4 and was not able to start seafile with the start unit at boottime.
It always complained about, that the seafile-data directory did not exist.

First I thought about user privileges, file permissions and ownership etc.
Nothing helped.

I am running seafile as a user seafile and I have a softlink from /home/seafile/seafile-server-latest/seafile-data to an external USB drive, as it is not possible during seafile setup to change the seafile-data location and you HAVE to use a softlink to put your data e.g. to an external USB drive. SD cards are big nowadays, but not THAT big to hold a full instance of seafile, especially in pi4s :wink:

The manual at https://seafile.gitbook.io/seafile-server-manual/deploying-seafile-under-linux/other-deployment-notes/start-seafile-at-system-bootup states the contents of the seafile.service file, and it is, more or less correct, BUT:

Be aware , if you are using an USB drive, like I do with raspbian (or maybe other debina distros), it is likely, that the f*** systemd does not start USB before your seafile.service unit will be executed and therefor seafile.service will fail to start!

(infact seafile.sh start script throws an error)…

In my case systemctl status seafile.service gave me the following after boot:
Nov 17 21:58:12 seafile.sh[487]: Error: there is no seafile server data directory.
Nov 17 21:58:12 seafile.sh[487]: Have you run setup-seafile.sh before this?

BTW: this error is a little bit missleading and could be more exact…

That said, seafile.sh, which infact is called by the seafile.service unit will not detect your seafile-data directory, as the symlink at the time, when seafile.service unit is executed, is empty, as the USB disk is not mounted. In the seafile.sh script the if statement tests with the ! -d option, which is ok, as it will check if a directory behind the softlink exists, but as said, if the USB drive is not mounted at that point in time, the directory is not there and the softlink is empty.

Long story short:

You might consider to add the below to your seafile.service file (in my case the external mount unit is media-extsea.mount):

~ $ cat /etc/systemd/system/seafile.service
[Unit]
Description=seafile
#add mysql.service or postgresql.service depending on your database to the line below
After=network.target media-extsea.mount

[Service]
Type=forking
ExecStart=/home/seafile/seafile-server-latest/seafile.sh start
ExecStop=/home/seafile/seafile-server-latest/seafile.sh stop
User=seafile
Group=seafile

[Install]
WantedBy=multi-user.target

############################################################################
You can check what is mounted when with the following:
#systemctl list-units --type=mount