Can't start via systemd

Hi,
I noticed shortly that I can’t start seafile via systemd or similar services.
When I start the server by logging into the seafile user (via su) and executing the seafile.sh and seahub.sh scripts (seahub in fastcgi) everything runs fine but when I try to automate the process e.g. via systemd I get django errors in the logfile (example, happens also with other tables at the end).
It seems that django couldn’t find specfic tables in the db. The strange thing is: The django backend for sqlite shows up in the stacktrace, but I use MySQL/MariaDB as my backend (specified in seahub_settings.py, works when started manually).
For me it looks like seahub is ignoring the settings file when started via systemd and uses the default values.
In my understanding, the .pyc file is recreated on every start of seahub. I deleted the file and started seahub again and no new .pcy appears. What could be the problem here?

Greetings,
Levin

1 Like

We need more infos: System? Whats the content of your systems service files? Does Seafile start after system startup?

Hi,
I’m running a Ubuntu 16.04 LTS with the newest kernel but I experienced the problem also on other Ubuntu Servers with other kernels.
These are my service files (mostly from the manual): [Links broken. See below].
I didn’t try to start seafile at startup because there are also other applications on my server that can’t be shut down. But I don’t think that it’s gonna work from startuo when it doesn’t work manually.
Btw: For example seafdav runs great, also in systemd mode. Its only seahub.

imho seahub can’t start bevor seafile is running

Please post the content of the files in this forum. The second link does not work for me.

Thank you for your help but I don’t think thats the problem here. If I try to start seahub it starts w/o a error message, only when I try to access seahub it gives these error messages in the django log and shows a Page unavailable html page. Maybe I didn’t said that clear enough. Also, the dependencies of seahub (has to start after seafile) are specified in my .service file. (See my next post)

For some reason both links don’t work. mh.
seafile.service:

[Unit]
Description=Seafile
# add mysql.service or postgresql.service depending on your database to the line below
Requires=mysql.service
After=network.target
After=mysql.service

[Service]
User=seafile
Group=seafile
Type=oneshot
ExecStart=/bin/bash /home/seafile/haiwen/seafile-server-latest/seafile.sh start
RemainAfterExit=yes
ExecStop=/bin/bash /home/seafile/haiwen/seafile-server-latest/seafile.sh stop

[Install]
WantedBy=multi-user.target

seahub.service:

[Unit]
Description=Seafile
# add mysql.service or postgresql.service depending on your database to the line below
Requires=mysql.service seafile.service
After=network.target mysql.service seafile.service

[Service]
User=seafile
Group=seafile
Type=oneshot
ExecStart=/bin/bash /home/seafile/haiwen/seafile-server-latest/seahub.sh start-fastcgi 8000
RemainAfterExit=yes
ExecStop=/bin/bash /home/seafile/haiwen/seafile-server-latest/seahub.sh stop

[Install]
WantedBy=multi-user.target

You should change your service files according to: https://github.com/haiwen/seafile-docs/blob/master/deploy/start_seafile_at_system_bootup.md So it is easier for us to help.

I took the most parts from the manual. I only added some small things.
But I now copy-pasted the .service files from the manual and changed only the path.
Nothing changed in the behaviour.

Did you do a systemctl daemon-reload after that?

Yes. Why is the limit 8 chars? :smiley:

No one has an idea?
Should I fill out a bug report / issue on github?

Yes, I’d do that. The Seafile team does not have the ressources to test every system and setup according to @daniel.pan. They need to find a way to clear these kinds of problems before changing anything.

This is not Seafile issue. It is a configuration issue. The forum is the best place to discuss it.

The /bin/bash in front of the command is very very very likely to be the issue. See also https://serverfault.com/a/614842

E.g. the server installer did always work and also makes use of systemd.

1 Like

As I already said (wrote in the forum and in the summary in the issue description) I now use exactly the template from the seafile manual (with customized paths and fastcgi for seahub, I’m runnning seahub behind a apache reverse proxy). Without /bin/bash. As I wrote twice.
If this is a configuration issue the issue is also in the seafile manual.
btw: I tried this some time ago with a script in /etc/init.d that uses sudo to run seafile/seahub as user seafile and the same error message came up.

Is there anything in journalctl -xn 1000 -u seafile.service / seahub.service?

I give it a quick try in a VM and report if it works or not, soon.

So the test finished. It works.

● seafile.service - Seafile Server
   Loaded: loaded (/etc/systemd/system/seafile.service; enabled; vendor preset: enabled)
   Active: active (exited) since Sun 2017-06-25 14:49:24 UTC; 1min 41s ago
  Process: 12946 ExecStart=/opt/seafile/seafile-server-latest/seafile.sh start (code=exited, status=0/SUCCESS)
 Main PID: 12946 (code=exited, status=0/SUCCESS)
    Tasks: 60 (limit: 4915)
   CGroup: /system.slice/seafile.service
           ├─12971 /opt/seafile/seafile-server-6.0.9/seafile/bin/seafile-controller -c /opt/seafile/ccnet -d /opt/seafil
           ├─12973 ccnet-server -F /opt/seafile/conf -c /opt/seafile/ccnet -f /opt/seafile/logs/ccnet.log -d -P /opt/sea
           ├─12979 /usr/bin/python2.7 -m wsgidav.server.run_server runfcgi --log-file /opt/seafile/logs/seafdav.log --pi
           └─12980 seaf-server -F /opt/seafile/conf -c /opt/seafile/ccnet -d /opt/seafile/seafile-data -l /opt/seafile/l

Jun 25 14:49:20 debian-2gb-fra1-01 systemd[1]: Starting Seafile Server...
Jun 25 14:49:21 debian-2gb-fra1-01 seafile.sh[12946]: [06/25/17 14:49:21] ../common/session.c(132): using config file /o
Jun 25 14:49:21 debian-2gb-fra1-01 seafile.sh[12946]: Starting seafile server, please wait ...
Jun 25 14:49:24 debian-2gb-fra1-01 systemd[1]: Started Seafile Server.
● seahub.service - Seafile Seahub
   Loaded: loaded (/etc/systemd/system/seahub.service; enabled; vendor preset: enabled)
   Active: active (exited) since Sun 2017-06-25 14:49:30 UTC; 1min 57s ago
  Process: 13042 ExecStart=/opt/seafile/seafile-server-latest/seahub.sh start-fastcgi 8000 (code=exited, status=0/SUCCES
 Main PID: 13042 (code=exited, status=0/SUCCESS)
    Tasks: 6 (limit: 4915)
   CGroup: /system.slice/seahub.service
           ├─13061 python2.7 /opt/seafile/seafile-server-6.0.9/seahub/manage.py runfcgi host=127.0.0.1 port=8000 pidfile
           ├─13062 python2.7 /opt/seafile/seafile-server-6.0.9/seahub/manage.py runfcgi host=127.0.0.1 port=8000 pidfile
           ├─13063 python2.7 /opt/seafile/seafile-server-6.0.9/seahub/manage.py runfcgi host=127.0.0.1 port=8000 pidfile
           ├─13064 python2.7 /opt/seafile/seafile-server-6.0.9/seahub/manage.py runfcgi host=127.0.0.1 port=8000 pidfile
           ├─13065 python2.7 /opt/seafile/seafile-server-6.0.9/seahub/manage.py runfcgi host=127.0.0.1 port=8000 pidfile
           └─13066 python2.7 /opt/seafile/seafile-server-6.0.9/seahub/manage.py runfcgi host=127.0.0.1 port=8000 pidfile

Jun 25 14:49:24 debian-2gb-fra1-01 systemd[1]: Starting Seafile Seahub...
Jun 25 14:49:24 debian-2gb-fra1-01 seahub.sh[13042]: LANG is not set in ENV, set to en_US.UTF-8
Jun 25 14:49:24 debian-2gb-fra1-01 seahub.sh[13042]: LC_ALL is not set in ENV, set to en_US.UTF-8
Jun 25 14:49:24 debian-2gb-fra1-01 seahub.sh[13042]: Starting seahub (fastcgi) at 127.0.0.1:8000 ...
Jun 25 14:49:30 debian-2gb-fra1-01 systemd[1]: Started Seafile Seahub.

And I’ve verified Seahub is reachable.

Nope, the log is clean and looks nearly exactly as yours.

Thank you for your test. My systemctl status output looks nearly the same as yours. Only the LANG is not set in ENV... message doesn’t appear in my logs (neither it does on a manual start) and I use Seafile 6.1.1 instead of 6.0.9. But I don’t think this makes a difference, as I said I ran into this problem before on a completely independent system.
Is your VM a Ubuntu 16.04?

Debian Stretch

It seems like a config issue on my side but I really don’t know where. It doesn’t make any sense that the seahub settings file is ignored (?) if seahub is started via systemd. Where is a related config file?..