korpling / ANNIS

ANNIS is an open source, versatile web browser-based search and visualization architecture for complex multilevel linguistic corpora with diverse types of annotation.
http://corpus-tools.org/annis/
Apache License 2.0
67 stars 25 forks source link

Annis as a service in `/etc/systemd/system` #861

Closed gcelano closed 1 day ago

gcelano commented 6 days ago

There is a problem with Annis finding the directory for the database in application.properties. If I leave the default values

annis.webservice-config=${user.home}/.annis/service.toml spring.datasource.url=jdbc:h2:file:${user.home}/.annis/v4/frontend_data.h2

Annis starts, but no database is shown. In fact, my system user/group is annis, and therefore I guess there may be a problem with the value of ${user.home}, because the database is in /home/celano/.annis ...

If I try to substitute ${user.home} with /home/celano/, then I get the error:

java.net.ConnectException: Failed to connect to localhost/[0:0:0:0:0:0:0:1]:5711

thomaskrause commented 6 days ago

Can you post your /etc/systemd/system/annis.service file? It looks, indeed, that the service is or was started as the wrong user. Please also post the output of the command

sudo systemctl status annis.service
gcelano commented 6 days ago

● annis.service - ANNIS corpus search and visualization Loaded: loaded (/etc/systemd/system/annis.service; enabled; preset: enabled) Active: active (running) since Thu 2024-07-04 17:17:01 CEST; 11s ago Main PID: 9883 (java) Tasks: 134 (limit: 309222) Memory: 1.3G CPU: 56.130s CGroup: /system.slice/annis.service └─9883 /usr/bin/java -jar /usr/local/bin/annis-4.12.2-server.jar --spring.config.location=file:/home/celano/.annis/application.properties

Jul 04 17:17:06 varro java[9883]: 2024-07-04 17:17:06.068 INFO 9883 --- [0.1-5712-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispat> Jul 04 17:17:06 varro java[9883]: 2024-07-04 17:17:06.068 INFO 9883 --- [0.1-5712-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet' Jul 04 17:17:06 varro java[9883]: 2024-07-04 17:17:06.069 INFO 9883 --- [0.1-5712-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 1 ms Jul 04 17:17:06 varro java[9883]: 2024-07-04 17:17:06.109 WARN 9883 --- [0.1-5712-exec-1] c.v.s.DefaultDeploymentConfiguration : Jul 04 17:17:06 varro java[9883]: ================================================================= Jul 04 17:17:06 varro java[9883]: Vaadin is running in DEBUG MODE. Jul 04 17:17:06 varro java[9883]: Add productionMode=true to web.xml to disable debug features. Jul 04 17:17:06 varro java[9883]: To show debug window, add ?debug to your application URL. Jul 04 17:17:06 varro java[9883]: ================================================================= Jul 04 17:17:06 varro java[9883]: 2024-07-04 17:17:06.496 WARN 9883 --- [0.1-5712-exec-5] c.v.spring.navigator.SpringViewProvider : No SpringViews found

Screenshot from 2024-07-04 17-15-22

thomaskrause commented 2 days ago

The application.properties file is located in another users' home folder, which might be a problem when the process running as annis user tries to access it because it might lack the access right for this. I would check if the annis user and its home directory /home/annis/ actually exists and move all files to the /home/annis/ directory so it is always accessible for the annis user.

Or as an alternative, you could the service to use the celano to start the service.

[Unit]
Description=ANNIS corpus search and visualization

[Service]
Type=simple
ExecStart=/usr/local/bin/annis-gui-4.12.2-server.jar --spring.config.location=file:/home/celano/.annis/application.properties
Environment=""
User=celano
Group=celano
WorkingDirectory=/usr/local/bin

[Install]
WantedBy=multi-user.target

Then, the ${user.home} placeholde should be resolved correctly.

annis.webservice-config=${user.home}/.annis/service.toml
spring.datasource.url=jdbc:h2:file:${user.home}/.annis/v4/frontend_data.h2
gcelano commented 1 day ago

I have moved /.annis to the home directory of the user annis, changed file ownership, and now it works.