Server Operation

Introduction

Two software components are required for operating the datasqill server:

  • datasqill Server
    • as SpringBoot application or
    • as TomEE with datasqill Server App.
  • H2 Database (datasqill repository)

Software

The datasqill server is operated either as a web app in a TomEE server (version 3.x) or as a SpringBoot application (version ≥ 4.0).

Note: All subsequent Unix commands are to be executed as user datasqill!

Distinction Crontab or Linux System Services

There are two ways to start the two datasqill components:

  1. via Crontab entries
  2. via Linux system services

The procedures used in operation for starting and stopping the H2 database and the datasqill server depend on this.

To check which procedure was set up during installation for controlling the components, use:

crontab -l | grep -q h2.sh && echo "Server is managed by crontab"
systemctl status h2 >> /dev/null && echo "Server is managed by systemctl"

Exactly one of the following outputs should appear:

  • "Server is managed by crontab" or
  • "Server is managed by systemctl".

Distinction SpringBoot Application or WebApp in TomEE

Up to version 3.5.9, the datasqill server was delivered as a web app in TomEE. With the switch to 4.0.0, SpringBoot was used as the container, which simplifies operation.

To check which container, SpringBoot or TomEE, a datasqill installation uses:

[[ -f /home/datasqill/datasqill-server/webapps/datasqill-server.war ]] && echo "Deployment as web app in TomEE"
[[ -f /home/datasqill/lib/datasqill-server.war ]] && echo "Deployment as SpringBoot application"

Then exactly one of the following messages should appear:

  • "Deployment as SpringBoot application" or
  • "Deployment as web app in TomEE".

The various procedures and the setup and control of the software components are described in the following sections:

Control with Crontab

Setup (Crontab)

To automatically start H2 via Crontab entries during boot, open the Crontab editor as user datasqill:

$ crontab -e
```

and add the following line there:

@reboot /home/datasqill/h2server/h2.sh 2>&1 >> /home/datasqill/h2.log

If TomEE is used as the container, add the following line via the same path (crontab -e):

@reboot . /home/datasqill/bin/datasqill.env && /opt/apache-tomee/bin/catalina.sh start 2>&1 >> /home/datasqill/tomee.log

For SpringBoot as container, add the following Crontab entry:

@reboot /home/datasqill/bin/datasqill 2>&1 >> /home/datasqill/datasqill.log

Status (Crontab)

Whether the H2 database is running can be verified with the following command:

$ pgrep -a h2
1011 /bin/bash /home/datasqill/h2server/h2.sh

When using TomEE as container, verify with:

$ pgrep -a -f tomee
1052 /usr/bin/java -Djava.util.logging.config.file=...

For the SpringBoot container, verify with:

$ pgrep -a -f /home/datasqill/lib/datasqill-server.war
627 java -Djdbc.drivers=...

Manual Stop (Crontab)

When using TomEE as container, use this command to stop it:

/opt/apache-tomee/bin/shutdown.sh

If the SpringBoot container is in use, stop with:

pkill -f /home/datasqill/lib/datasqill-server.war

To stop the running H2 database, use the following command:

$ /home/datasqill/h2server/stoph2.sh

Pay attention to the correct order: the datasqill container must be shut down before H2.

Manual Start (Crontab)

To perform a manual start of H2, use:

/home/datasqill/h2server/h2.sh

If TomEE is used as container, use for manual start:

/opt/apache-tomee/bin/catalina.sh start

When using the SpringBoot container, use for manual start:

/home/datasqill/bin/datasqill

Here too, pay attention to the correct order: H2 must be started before the datasqill container.

Control with Linux System Services

Setup (Systemctl)

The Linux system service for H2 can be set up with this script (adjust port and home user if necessary): Execution must be done as root

#!/bin/bash
H2PORT=9092
H2HOME=/home/datasqill/h2server
if [[ ! -f /etc/systemd/system/h2-$H2PORT.service ]]
then
  echo "  Creating systemd service file for H2"
  cat <<-EOF_SERVICE > /etc/systemd/system/h2-$H2PORT.service
[Unit]
Description=Datasqill H2 Repository $H2PORT
After=network.target

[Service]
ExecStart=$H2HOME/h2ctl.sh --foreground start
ExecStop=$H2HOME/h2ctl.sh --foreground stop
WorkingDirectory=$H2HOME
Restart=always
Type=simple
User=datasqill
Group=datasqill
KillMode=none

StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=h2-9092.service

[Install]
WantedBy=multi-user.target
EOF_SERVICE
  systemctl daemon-reload
else
  echo "  systemd service file for H2 repository already exists, nothing to be done"
fi
...

To set up the TomEE container as a Linux service, execute the following script. For the SpringBoot container, use the corresponding systemd unit. (See German version for full scripts.)

Status (Systemctl)

Whether the H2 database is running can be verified with:

$ systemctl status h2-9092
● h2-9092.service - Datasqill H2 Repository 9092
   Loaded: loaded (/etc/systemd/system/h2-9092.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2023-08-11 16:49:56 CEST; 49min ago
...

Manual Stop (Systemctl)

When using TomEE as datasqill container, stop with:

sudo systemctl stop tomee

For the SpringBoot container:

sudo systemctl stop datasqill-17491

Stop the Linux service for H2 with:

sudo systemctl stop h2-9092

Pay attention that the datasqill container is stopped before H2.

Manual Start (Systemctl)

The manual start of the services is executed with the "start" command.

For H2:

sudo systemctl start h2-9092

For TomEE as container:

sudo systemctl start tomee

For the SpringBoot container:

sudo systemctl start datasqill-17491

The H2 database must always be started before the datasqill container.