Thursday, December 13, 2018

Create service for starting / stopping Pentaho Server (Ubuntu 16.04)

Background: I recently performed an archive install of the Pentaho Server (v8.2) on a server with Ubuntu 16.04 OS. After performing the archive installation according to Pentaho documentation, I wanted to ensure the Pentaho Server would start and stop upon starting and stopping the machine.

I've installed services before by placing the shell script within /etc/init.d and executing update-rc.d with the defaults. For some reason that I discovered later, this approach was not working for me. In doing some research, I discovered that this approach is quite old (System V) and the newer OSs use systemd for services. In fact, even when using the 'old' approach, the OS converts the scripts to systemd which at times leads to problems.

Here are the steps that I performed to create the service and register it with systemd. For the most part, I just followed the steps outlined in the Apache Tomcat documentation (Step 5: Create a systemd Service File) regarding how to register the Tomcat server as a service.

  • Confirm the Ubuntu version (Verify Release is 16.04)

          lsb_release -a
  • Log into the Pentaho server as root or with sudo permissions
  • Navigate to /etc/systemd/system
  • Create the file name pentaho.service with the following contents (NOTE: contents may change depending upon your environment)
[Unit]
Description=Pentaho Server
After=network.target

[Service]
Type=forking

Environment=PENTAHO_JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre
Environment=JRE_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre
Environment=CATALINA_PID=/opt/pentaho/server/pentaho-server/tomcat/temp/tomcat.pid

ExecStart=/opt/pentaho/server/pentaho-server/start-pentaho.sh
ExecStop=/opt/pentaho/server/pentaho-server/stop-pentaho.sh

User=pentaho
Group=pentaho
UMask=0007
RestartSec=10
Restart=always

[Install]
WantedBy=multi-user.target
  • Run the following command to load the service
        systemctl daemon-reload
  • Start the Pentaho Server (make sure the server is not already running)
        systemctl start pentaho
  • Check the status of the Pentaho Server / service
        systemctl status pentaho

NOTE: If any changes are made to the script, you need to reload them via systemctl daemon-reload. Also, apparently systemd is also used by RHEL and CentOS.