Overview
The Cantaloupe Image Server can be run with the following command.
java -Dcantaloupe.config=cantaloupe.properties -Xmx2g -jar cantaloupe-5.0.5.jar
However, with this method, the Cantaloupe server stops when the SSH connection is lost, for example.
Here I introduce how to run it as a service.
Method
- Create a service file: Create a service file (e.g.,
cantaloupe.service) in the/etc/systemd/system/directory withsudoprivileges.
[Unit]
Description=Cantaloupe Image Server
[Service]
User=ubuntu
# Please modify the following paths as appropriate
WorkingDirectory=/home/ubuntu/cantaloupe-5.0.5
ExecStart=/usr/bin/java -Dcantaloupe.config=cantaloupe.properties -Xmx2g -jar cantaloupe-5.0.5.jar
SuccessExitStatus=143
[Install]
WantedBy=multi-user.target
In this file, the Java command to execute is specified in ExecStart. Also, User and WorkingDirectory need to be set appropriately.
- Reload the service: To apply the changes, reload systemd with the following command.
sudo systemctl daemon-reload
- Start the service: Start the service with the following command.
sudo systemctl start cantaloupe
- Enable the service: To make the service start automatically at system boot, run the following command.
sudo systemctl enable cantaloupe
- Check the service status: To check the status of the service, use the following command.
sudo systemctl status cantaloupe
Note: In this example, the Java path and Cantaloupe installation path need to be modified as appropriate. Also, replace User with the user that will run Cantaloupe. For detailed service file configuration, please refer to the systemd documentation.
Summary
You can confirm that it is running as a service as shown below. I hope this serves as a useful reference.
sudo systemctl status cantaloupe
● cantaloupe.service - Cantaloupe Image Server
Loaded: loaded (/etc/systemd/system/cantaloupe.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2023-11-16 03:52:24 UTC; 6min ago
Main PID: 33204 (java)
Tasks: 31 (limit: 4667)
Memory: 116.2M
CPU: 4.408s
CGroup: /system.slice/cantaloupe.service
└─33204 /usr/bin/java -Dcantaloupe.config=cantaloupe.properties -Xmx2g -jar cantaloupe-5.0.5.jar