Versions Compared

Key

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

Table of Contents

Introduction

  • For Unix systems a 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 to write of writing systemd service files , - however, the sections below chapters explain the best practices for use of systemd  with JS7 componentsproducts.

Controller

Location of Service File

When The following service file will be created when extracting the Controller instance from the downloaded archive then this will create the following file:

  • controller/bin/controller.service-example

You can rename the file to controller.service (or to any other name with the extension .service) and move the file to one of the known locations for systemd unit files such as:

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

When using JS7 - Automated Installation and Update then the systemd service file can be automatically created.

Controller Service File

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

Code Block
languagebash
titleExample for Controller service file
linenumberstrue
collapsetrue
[Unit]
Description=SOS JS7 Controller -id=jobschedulercontroller
After=syslog.target
After=network.target

[Service]
# Optionally set JAVA_HOME environment variable if not specified with the Controller's Instance Start Script
# Environment="JAVA_HOME=/usr/lib/jvm/java-1.8-openjdk/"
# Optionally set JAVA_OPTIONS
# Environment="JAVA_OPTIONS='-Djavax.net.debug=sslXmx500m'"
Type=forking
KillMode=process
# default <JS7_CONTROLLER_PID_FILE_DIR> = <INSTALL_PATH>/var/logs
PIDFile=/var/sos-berlin.com/js7/controller>controller/logs/controller.pid
ExecStart=/opt/sos-berlin.com/js7/controller/bin/controller_instance.sh start
ExecStartPost=/bin/sleep 1
ExecStop=/opt/sos-berlin.com/js7/controller/bin/controller_instance.sh stop
ExecReload=/opt/sos-berlin.com/js7/controller/bin/controller_instance.sh restart
User=js7
StandardOutput=syslogjournal+console
StandardError=syslogjournal+console
TimeoutStopSec=60
TasksMax=infinity

[Install]
WantedBy=multi-user.target

...

  • 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. Consider 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 to in which the JDK is installed.
    • If a JRE is used then specify the folder to 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 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 If not otherwise specified by the Instance Start Script then the file is will be located in the logs directory.
  • ExecStart, ExecStop, ExecReload The operation to start, to stop and to restart operations for the Controller is are performed by running the Controller's Instance Start Script.
  • User=js7 The example assumes that the Controller is operated for 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

When The following file will be created when extracting the Agent from the downloaded archive then this will create the following file:

  • agent/bin/agent.service-example

You can rename the file to agent.service (or to any other name with the extension .service) and move the file to one of the known locations for systemd unit files such as:

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

When using JS7 - Automated Installation and Update then the systemd service file can be automatically created.

Agent Service File

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

Code Block
languagebash
titleExample for Agent service file
linenumberstrue
collapsetrue
[Unit]
Description=SOS JS7 Agent -port=4445
After=syslog.target
After=network.target

[Service]
# Optionally set JAVA_HOME environment variable if not specified with the Agent's Instance Start Script
# Environment="JAVA_HOME=/usr/lib/jvm/java-1.8-openjdk/"
# Optionally set JAVA_OPTIONS
# Environment="JAVA_OPTIONS='-Djavax.net.debug=sslXmx256m'"
Type=forking
KillMode=process
# default <JS7_AGENT_PID_FILE_DIR> = <INSTALL_PATH>/var_<JS7_AGENT_HTTP_PORT>/logs
PIDFile=/var/sos-berlin.com/js7/agent/logs/agent.pid
ExecStart=/opt/sos-berlin.com/js7/agent/bin/agent_4445.sh start
ExecStartPost=/bin/sleep 1
ExecStop=/opt/sos-berlin.com/js7/agent/bin/agent_4445.sh stop
ExecReload=/opt/sos-berlin.com/js7/agent/bin/agent_4445.sh restart
User=js7
StandardOutput=syslogjournal+console
StandardError=syslogjournal+console
TimeoutStopSec=60
TasksMax=infinity

[Install]
WantedBy=multi-user.target

...

  • 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. Consider 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 to in which the JDK is installed.
    • If a JRE is used then specify the folder to 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 operation to start, to stop and to restart operations for the Agent is 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 Cockpit start script jetty.sh start script will switch to this account independently from of the fact that the start script is executed e.g.  by systemd using the root account.
  • For A sample service file for use with systemd find a sample service file from  is to be found at./bin/joc.service-example file.

You can rename the file to joc.service (or to any other name with the extension .service) and move the file to one of the known locations for systemd unit files such as:

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

When using JS7 - Automated Installation and Update then the systemd service file can be automatically created.

JOC Cockpit Service File

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

Code Block
languagebash
titleExample for JOC Cockpit service file
linenumberstrue
collapsetrue
[Unit]
Description=Jetty for SOS JS7 JOC Cockpit
After=syslog.target
After=network.target

[Service]
# Optionally set JAVA_HOME environment variable if necessary
# Environment="JAVA_HOME=/usr/lib/jvm/java-1.8-openjdk"
# Optionally set JAVA_OPTIONS
# Environment="JAVA_OPTIONS='-Djavax.net.debug=sslXmx500m'"
Type=forking
PIDFile=/var/sos-berlin.com/js7/joc/joc.pid
ExecStart=/opt/sos-berlin.com/js7/joc/jetty/bin/jetty.sh start
ExecStartPost=/bin/sleep 1
ExecStop=/opt/sos-berlin.com/js7/joc/jetty/bin/jetty.sh stop
ExecReload=/opt/sos-berlin.com/js7/joc/jetty/bin/jetty.sh restart
User=js7
StandardOutput=syslogjournal+console
StandardError=syslogjournal+console
SuccessExitStatus=143
TimeoutStopSec=60

[Install]
WantedBy=multi-user.target

...

  • 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. withwith, for example:
    • the 
    • the Instance Start Script ./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 forwith. Consider 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 to in which the JDK is installed.
    • If a JRE is used then specify the folder to 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 e.g. /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 operation to start, to stop and to restart operations for the Agent is 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

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

Code Block
languagebash
titleExample for enabling JS7 components
linenumberstrue
collapsetrue
# make systemd read changes to service files
systemctl daemon-reload

# make systemd create a startup/shutdown configuration
systemctl enable controller
systemctl enable agent
systemctl enable joc

Explanations:

  • Consider Ensure that the the  controller service name controller corresponds to a service file name the controller.service service file name.
  • For unique service names users can rename the service file, for example to js7_controller.service.
  • The command systemctl daemon-reload has to be re-executed after any later change to a service file.

How to run systemd Service Files

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

Code Block
languagebash
titleExample for managing JS7 components
linenumberstrue
collapsetrue
# start, stop, restart and get status information of the Controller
systemctl start controller
systemctl stop controller
systemctl restart controller
systemctl status controller

Explanations:

  • Consider Ensure that the controller service name controller corresponds to a service file name the controller.service. service file name.
  • For unique service names users can rename the service file, for example to js7_controller.service.
  • The above examples apply similarly apply to the Agent and JOC Cockpit.

...