Hi,
Starting Kolibri automatically and easily maintaining it as a service is important for convenience and security.
So I created a user kolibri with home directory /opt/kolibri. The following is used to test running Kolibri:
sudo -u kolibri /bin/bash -c “cd /opt/kolibri; /usr/bin/python /opt/kolibri/bin/kolibri-v0.7.0.pex start”
It worked fine.
Next I try starting with a systemd service as follows:
$ cat /usr/lib/systemd/system/kolibri-pex.service
[Unit]
Description=Kolibri (pex) server
[Service]
Type=simple
PIDFile=/run/kolibri-pex.pid
#WorkingDirectory=/opt/kolibri
User=kolibri
SyslogIdentifier=kolibri-pex
ExecStart=/usr/bin/python /opt/kolibri/bin/kolibri-v0.7.0.pex start
ExecStop=/usr/bin/python /opt/kolibri/bin/kolibri-v0.7.0.pex stop
[Install]
WantedBy=multi-user.target
Normally type should be forking instead of simple since Kolibri goes into daemon mode by default. However if I put forking then starting the service just hangs.
Followed by
sudo systemctl start kolibri-pex
sudo systemctl status kolibri-pex
● kolibri-pex.service - Kolibri (pex) server
Loaded: loaded (/usr/lib/systemd/system/kolibri-pex.service; disabled; vendor preset: disabled)
Active: inactive (dead)Jan 27 13:44:57 linux.local kolibri-pex[22135]: http://127.0.0.1:8080/
Jan 27 13:44:57 linux.local kolibri-pex[22135]: INFO Going to daemon mode, logging to /opt/kolibri/.kolibri/server.log
Jan 27 13:44:57 linux.local kolibri-pex[22135]: 0 static files copied to ‘/opt/kolibri/.kolibri/static’, 406 unmodified.
Jan 27 13:44:57 linux.local kolibri-pex[22135]: Operations to perform:
Jan 27 13:44:57 linux.local kolibri-pex[22135]: Apply all migrations: contenttypes, logger, kolibriauth, admin, exams, morango, content, device, auth, sessions
Jan 27 13:44:57 linux.local kolibri-pex[22135]: Running migrations:
Jan 27 13:44:57 linux.local kolibri-pex[22135]: No migrations to apply.
Jan 27 13:44:57 linux.local kolibri-pex[22135]: Your models have changes that are not yet reflected in a migration, and so won’t be applied.
Jan 27 13:44:57 linux.local kolibri-pex[22135]: Run ‘manage.py makemigrations’ to make new migrations, and then re-run ‘manage.py migrate’ to apply them.
Jan 27 13:44:59 linux.local kolibri-pex[22147]: INFO Running Kolibri with the following settings: kolibri.deployment.default.settings.base
However in the browser http://127.0.0.1:8080 I get site cannot be reached, even if I uncomment > WorkingDirectory=/opt/kolibri
Kolibri’s log shows:
INFO 2018-01-27 13:53:57,261 apps Running Kolibri with the following settings: kolibri.deployment.default.settings.base
INFO 2018-01-27 13:53:57,391 cli Running update routines for new version…
INFO 2018-01-27 13:53:57,642 cli Running ‘kolibri start’ as daemon (system service)
INFO 2018-01-27 13:53:57,651 cli Kolibri running on:INFO 2018-01-27 13:53:57,651 cli Going to daemon mode, logging to /opt/kolibri/.kolibri/server.log
INFO 2018-01-27 13:53:57,806 ping Attempting a ping.
INFO 2018-01-27 13:53:57,812 utils Started new MESSAGEPROCESSOR thread ID#oscar-cold-hot-artist
INFO 2018-01-27 13:53:57,813 utils Started new SCHEDULER thread ID#cup-illinois-mirror-nuts
INFO 2018-01-27 13:53:57,815 utils Started new WORKERMESSAGEHANDLER thread ID#grey-wisconsin-nitrogen-bulldog
INFO 2018-01-27 13:53:57,874 ping data: {“instance_id”: “f7242de04a60551bc038c8ab4abe8369”, “version”: “0.7.0”, “mode”: “”, “platform”: “Linux-4.14.14-1-MANJARO-x86_64-with-arch-Manjaro-Linux”, “sysversion”: “3.6.4 (default, Dec 23 2017, 19:07:07) \n[GCC 7.2.1 20171128]”, “database_id”: “9eae25984d974535b72540fd5d6bbbe1”, “system_id”: “”, “node_id”: “fd2d9eb6c940191f3a28”, “language”: “”, “uptime”: 0}
INFO 2018-01-27 13:53:59,216 apps Running Kolibri with the following settings: kolibri.deployment.default.settings.base
Do you have a ready made kolibri systemd service definition? If not, how to debug this case?
Best wishes