Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running eXist-db as a service #5454

Open
GilShalit opened this issue Sep 29, 2024 · 6 comments
Open

Running eXist-db as a service #5454

GilShalit opened this issue Sep 29, 2024 · 6 comments

Comments

@GilShalit
Copy link

GilShalit commented Sep 29, 2024

I am trying to run eXist-db as a Service with Ubuntu 22.04 and java 21 (the current versions).

eXist-db runs fine when started with sudo /home/ubuntu/eXist-db/bin/startup.sh. I followed the instructions on the site with service file:

[Unit]
Description=eXist-db Server
Documentation=https://exist-db.org/exist/apps/doc/
After=syslog.target

[Service]
Type=simple
User=existdb
Group=existdb
Environment="JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64"
Environment="JAVA_OPTS=-XX:+UseG1GC -XX:+UseStringDeduplication -XX:MaxRAMPercentage=75.0 >
ExecStart=/home/ubuntu/eXist-db/bin/startup.sh

[Install]
WantedBy=multi-user.target

The service runs on startup but eXist-db is not run. looking at the status I see:

Sep 29 13:16:15 ip-172-31-47-83 systemd[1]: Started existdb.service - eXist-db Server.
Sep 29 13:16:15 ip-172-31-47-83 (artup.sh)[1121]: existdb.service: Failed to execute /home/ubuntu/eXist-db/bin/startup.sh: Permission denied
Sep 29 13:16:15 ip-172-31-47-83 systemd[1]: existdb.service: Main process exited, code=exited, status=203/EXEC
Sep 29 13:16:15 ip-172-31-47-83 systemd[1]: existdb.service: Failed with result 'exit-code'.

The startup script is not run from the service file because of a problem with permissions yet the eXist-db home directory belongs (recursively) to existdb:existdb and so does the existdb.service file, so I don't see what the problem can be with permissions.

the user existdb:existdb was created with sudo useradd --system --shell /sbin/nologin --comment "eXist-db Service Account" existdb

This setup works fine with Ubuntu 20 and java 11, so I wonder if something subtle has changed.

@adamretter
Copy link
Contributor

eXist-db 6.x.x, 5.x.x, or 4.x.x require Java 8

@GilShalit
Copy link
Author

Thanks @adamretter. So are you saying java 21 is too high? The problem with this is that simply starting eXist-db from the command line works and I can access it, add TEI-Publisher etc, with Java 21.

So I still think the problem, as the error message implies, is with the permissions.

@reinhapa
Copy link
Member

reinhapa commented Sep 29, 2024

Sep 29 13:16:15 ip-172-31-47-83 systemd[1]: Started existdb.service - eXist-db Server.
Sep 29 13:16:15 ip-172-31-47-83 (artup.sh)[1121]: existdb.service: Failed to execute /home/ubuntu/eXist-db/bin/startup.sh: Permission denied
Sep 29 13:16:15 ip-172-31-47-83 systemd[1]: existdb.service: Main process exited, code=exited, status=203/EXEC
Sep 29 13:16:15 ip-172-31-47-83 systemd[1]: existdb.service: Failed with result 'exit-code'.

@GilShalit we use eXist 6.x using Java 21 without problems. We do no use any quotes for the environment though.

That is the service file we use:

[Unit]
Description=eXist Native XML Database
After=network.target
StartLimitIntervalSec=0

[Service]
Type=simple
Environment=JAVA_HOME=/path/zo/java
ExecStart=/path/to/exist/bin/startup.sh
SuccessExitStatus=143
Restart=always
RestartSec=1
User=bisonadm
Group=bisonadm

[Install]
WantedBy=multi-user.target

@adamretter
Copy link
Contributor

@GilShalit yes 21 is too high. You will find even if it starts, that certain operations cause exceptions when you run them.

You also have a permissions issue. You need to make sure the files are owned, and the scripts, are executable, by the user named in your systemd unit file.

@chakl
Copy link

chakl commented Sep 30, 2024

@GilShalit the service definition file you posted looks wrong. Unless this was a copypaste error, the JAVA_OPTS line is missing a closing quote and the redirect operator > does not make sense there.

Check validity of the service file with sudo systemd-analyze verify existdb.service (assuming you named the service file existdb.service). This should return no output if the file is valid. In your case, you probably get a warning about invalid syntax.

After editing the service file, reload systemd to ensure the changed service file is picked up: sudo systemctl daemon-reload. After that you should be able to manually start the service with sudo systemctl start existdb (again assuming the service is named existdb). If that works as expected, it should get started on reboot as well.

Another possible issue: make sure all files in $EXIST/data really belong to the existdb user and not root. Since you ran startup.sh as root with sudo before, some data files may be owned by root and may not be accessible for user existdb.

Yet another possibility: If the parent directory of your exist installation /home/ubuntu has strict permissions (eg mode 700), user existdb may not be allowed to execute startup.sh.

@line-o
Copy link
Member

line-o commented Sep 30, 2024

@GilShalit since you are running on Ubuntu 22.04 you may also want to be aware of this issue: #5345

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants