10. How to setup an SSH Monitor service#
If you want to automatically start your SSH Monitor IOC program at boot time,
you might want to create a system service either with systemd, OpenRC, Runit or SysVinit
(depending on your init system).
10.1. systemd service how-to#
Prerequisites:
On the host, you can create a systemd service like so (e.g. with procServ):
$ vi /usr/lib/systemd/system/myTargetMonitoring.service
+ > [Install]
+ > WantedBy=multi-user.target
+ >
+ > [Unit]
+ > After=network-online.target
+ > Wants=network-online.target
+ > Description=EPICS IOC monitoring target1
+ >
+ > [Service]
+ > ExecStart=procServ '--chdir' '/path/to/myTargetMonitoringTop/iocBoot/iocMyTargetMonitoring' '--foreground' '--logfile' '-' '--oneshot' 2000 '/path/to/myTargetMonitoringTop/iocBoot/iocMyTargetMonitoring/st_target1.cmd'
+ > Restart=on-failure
+ > DynamicUser=yes
+ > StateDirectory=epics/myTargetMonitoring
$ systemctl enable myTargetMonitoring
10.2. OpenRC service how-to#
🚧 TODO (help is welcome / appreciated) 🚧
10.3. Runit service how-to#
Prerequisites:
Most distros using Runit won’t store available services in the same directory. So let’s define a
$AVAILABLE_RUNIT_SERVICE_DIRenvironment variable holding the path to that directory. Most common paths are:/etc/sv(e.g. for Void Linux)/etc/runit//etc/runit/sv(e.g. for Artix Linux)
Most distros using Runit won’t store active services in the same directory. So let’s define a
$ACTIVE_RUNIT_SERVICE_DIRenvironment variable holding the path to that directory. Most common paths are:/service//var/service/(e.g. for Void Linux)/etc/service//run/runit/service/(e.g. for Artix Linux)
Create the active
myTargetMonitoringservice directory:# mkdir $AVAILABLE_RUNIT_SERVICE_DIR/myTargetMonitoring/Create a down file in the service directory, until the setup is completed:
# touch $AVAILABLE_RUNIT_SERVICE_DIR/myTargetMonitoring/downCreate a run file in the service directory:
# touch $AVAILABLE_RUNIT_SERVICE_DIR/myTargetMonitoring/run # chmod +x /service/service/myTargetMonitoring/run # vi /service/service/myTargetMonitoring/run > #!/bin/sh > exec 2>&1 # redirect output of stderr to stdout > > exec cd myTargetMonitoringTop/iocBoot/iocMyTargetMonitoring && ./st_target1.cmd > > # or e.g. with tmux: > # exec tmux new-session -d -s myTargetMonitoringTarget1 'cd /path/to/myTargetMonitoringTop/iocBoot/iocMyTargetMonitoring && ./st_target1.cmd' > > # or e.g. with procServ: > # exec procServ -n "myTargetMonitoringTarget1" -c /path/to/your/myTargetMonitoringTop/iocBoot/iocMyTargetMonitoring -i ^D^C 20000 ./st_target1.cmd
Enable logging:
# mkdir $AVAILABLE_RUNIT_SERVICE_DIR/myTargetMonitoring/log/ # touch $AVAILABLE_RUNIT_SERVICE_DIR/myTargetMonitoring/log/run # chmod +x $AVAILABLE_RUNIT_SERVICE_DIR/log/run $ vi $AVAILABLE_RUNIT_SERVICE_DIR/log/run > #!/bin/sh > exec svlogd -tt .
Enable
myTargetMonitoringand start it:# ln -s $AVAILABLE_RUNIT_SERVICE_DIR/myTargetMonitoring $ACTIVE_RUNIT_SERVICE_DIR # sv start myTargetMonitoring
10.4. SysVinit service how-to#
🚧 TODO (help is welcome / appreciated) 🚧