#
# JS7 Controller systemd service file
#
# Create an instance start script ./bin/controller_instance.sh
# as a copy of controller_instance.sh-example and
# edit the environment variables inside the instance script.
# See https://kb.sos-berlin.com/x/fwmGAw
#
# Customize this file in all placeholders <...> below such as <INSTALL_PATH>, 
# <JS7_CONTROLLER_ID>, <JS7_CONTROLLER_PID_FILE_DIR> and <JS7_CONTROLLER_USER>
# where <JS7_CONTROLLER_ID>, <JS7_CONTROLLER_PID_FILE_DIR> and <JS7_CONTROLLER_USER>
# have to carry the same values as the indicated environment variables
# $JS7_CONTROLLER_ID, $JS7_CONTROLLER_PID_FILE_DIR and $JS7_CONTROLLER_USER
# in the ./bin/controller_instance.sh script of the Controller. 
#
# root permissions are required for installation as a daemon
# copy this file to /usr/lib/systemd/system/js7_controller_<JS7_CONTROLLER_ID>.service
# call > systemctl daemon-reload
# for auto start ...
# call > systemctl enable js7_controller_<JS7_CONTROLLER_ID>
#
#
# systemd supports lots of fancy features, look here (and linked docs) for a full list: 
#   http://www.freedesktop.org/software/systemd/man/systemd.exec.html
#
# Note: this file ( /usr/lib/systemd/system/js7_controller_<JS7_CONTROLLER_ID>.service )
# will be overwritten on package upgrade, please copy the file to 
#
#  /etc/systemd/system/js7_controller_<JS7_CONTROLLER_ID>.service 
#  
# to make required changes.
# 
# systemd-delta can be used to check differences between the 
# two js7_controller_<JS7_CONTROLLER_ID>.service files.
#

[Unit]
Description=SOS JS7 Controller -id=<JS7_CONTROLLER_ID>
After=syslog.target
After=network.target

[Service]
# Set JAVA_HOME environment variable if required
# Environment="JAVA_HOME=/path/to/java_home"
# Environment="JAVA_OPTIONS="
Type=forking
KillMode=process
# default <JS7_CONTROLLER_PID_FILE_DIR> = <INSTALL_PATH>/var/logs
PIDFile=<JS7_CONTROLLER_PID_FILE_DIR>/controller.pid
ExecStartPost=/bin/sleep 1
ExecStart=<INSTALL_PATH>/bin/controller_instance.sh start
ExecStop=<INSTALL_PATH>/bin/controller_instance.sh stop
ExecReload=<INSTALL_PATH>/bin/controller_instance.sh restart
User=<JS7_CONTROLLER_USER>
StandardOutput=journal+console
StandardError=journal+console
TimeoutStopSec=60
TasksMax=infinity

[Install]
WantedBy=multi-user.target
