Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Introduction

  • A startup and shutdown configuration can be used for Unix systems that is executed by systemd running for the root account.
  • There are a number of ways how of writing systemd service files - however, the sections below explain the best practices for use of systemd  with JS7 components.

Controller

Location of Service File

The following file will be created when extracting the Controller instance from the downloaded archive:

...

  • /usr/lib/systemd/system
  • /etc/systemd/system

Controller Service File

The example file for the Controller daemon includes a number of placeholders that can be replaced as follows:

...

  • Environment="JAVA_HOME=..." Optionally the JAVA_HOME environment variable can be set to specify the location of the JVM. Alternatively this environment variable can be specified with
    • the Instance Start Script ./bin/controller_instance.sh of the Controller,
    • the profile, e.g. $HOME/.bashrc, of the user account that the Controller is operated for. Note that systemd will not run the user accounts' profile when switching to the user account.
    • If a JDK is used then specify the folder in which the JDK is installed.
    • If a JRE is used then specify the folder in which the JRE is installed.
  • Environment="JAVA_OPTIONS=..." Optionally set Java options, e.g. specify the heap size or debugging options, if not provided by the Controller's ./bin/controller_instance.sh Instance Start Script.
  • PIDFile=... The controller.pid PID file includes the process ID that is assigned when starting the Controller. If not otherwise specified by the Instance Start Script then the file will be located in the logs directory.
  • ExecStart, ExecStop, ExecReload The start, stop and restart operations for the Controller are performed by running the Controller's Instance Start Script.
  • User=js7 The example assumes that the Controller is operated with the js7 user account. If the JS7_USER environment variable is set from the Controller's Instance Start Script then the values have to match.

Agent

Location of Service File

The following file will be created when extracting the Agent from the downloaded archive:

...

  • /usr/lib/systemd/system
  • /etc/systemd/system

Agent Service File

The example file for the Agent daemon includes a number of placeholders that can be replaced as follows:

...

  • Environment="JAVA_HOME=..." Optionally the JAVA_HOME environment variable can be set to specify the location of the JVM. Alternatively this environment variable can be specified e.g. with
    • the Instance Start Script ./bin/agent_<port>.sh of the Agent,
    • the profile, e.g. $HOME/.bashrc, of the user account that the Agent is operated for. Note that systemd will not run the user accounts' profile when switching to the user account.
    • If a JDK is used then specify the folder in which the JDK is installed.
    • If a JRE is used then specify the folder in which the JRE is installed.
  • Environment="JAVA_OPTIONS=..." Optionally set Java options, e.g. to specify the heap size or debugging options, if not provided by the Agent's ./bin/agent_<port>.sh Instance Start Script.
  • PIDFile=... The agent.pid PID file includes the process ID that is assigned when starting the Agent. if not otherwise specified by the Instance Start Script then the file is located in the logs directory.
  • ExecStart, ExecStop, ExecReload The start, stop and restart operations for the Agent are performed by running the Agent's Instance Start Script.
  • User=js7 The example assumes that the Agent is operated for the js7 user account. If the JS7_USER environment variable is set from the Agent's Instance Start Script then the values have to match.

JOC Cockpit

Location of Service File

  • The JOC Cockpit will start for the user account that is specified during installation. The JOC Cockpitjetty.sh start script will switch to this account independently of the fact that the start script is executed e.g.  by systemd using the root account.
  • A sample service file for use with systemd is to be found at./bin/joc.service-example.

...

  • /usr/lib/systemd/system
  • /etc/systemd/system

JOC Cockpit Service File

The example file for the JOC Cockpit daemon includes a number of paths that are populated by the installer:

...

  • Environment="JAVA_HOME=..." Optionally the JAVA_HOME environment variable can be set to specify the location of the JVM. Alternatively this environment variable can be specified with, for example:
    • the  ./bin/agent_<port>.sh Start Script of the Agent Instance,
    • the profile, e.g. $HOME/.bashrc, of the user account that the Agent is operated with. Note that systemd will not run the user accounts' profile when switching to the user account.
    • If a JDK is used then specify the folder in which the JDK is installed.
    • If a JRE is used then specify the folder in which the JRE is installed.
  • Environment="JAVA_OPTIONS=..." Optionally set Java options, e.g. to specify the heap size or debugging options, if not not provided by some other location such as /etc/default/joc.
  • PIDFile=... The joc.pid PID file includes the process ID that is assigned when starting JOC Cockpit. By default the file is located in the JETTY_BASE directory.
  • ExecStart, ExecStop, ExecReload The start, stop and restart operations for the Agent are performed by running the JOC Cockpit Start Script.
  • User=js7 The example assumes that the Agent is operated for the js7 user account. If the JS7_USER environment variable is set from the Agent's Instance Start Script then the values have to match.

Operation with systemd

How to apply systemd Service Files

The following commands have to be executed after storing a service file to one of the known locations for systemd service files:

...

  • Ensure that the  controller service name corresponds to the controller.service service file name.
  • The command systemctl daemon-reload has to be re-executed after any later change to a service file.

How to run systemd Service Files

The following commands can be executed after saving a service file in one of the known locations for systemd service files:

...