Sorry to this late reply, I was offline,
I'm using systemd to start/stop iocs and carepeater on my linux
boxes to Spes project:
I'm working with CentOS 7 (RHEL equivalent).
I made a "systemd service" to every ioc which runs into my linux boxes.
Follow the example to my magnet ioc.
The file /etc/systemd/system/ioc.mag.service
contains:
###################################################################################
#
# Revision-Id: [email protected] - 11.09.2015
#
# Systemd service file to boot iocs and config tty
#
# Author Mauro Giacchini [email protected]
#
#
###################################################################################
[Unit]
Description=Starts MAG IOC using systemd
After=rc-local.service
[Service]
User=spesmgr
# Execute start with root
PermissionsStartOnly=true
# Configure the tty permissions
ExecStartPre=/home/spesmgr/topSPES/scripts/systemd/cfg_tty.sh
# Run as user spesmgr
EnvironmentFile=/home/spesmgr/topSPES/scripts/systemd/boot.iocs.service.env.sh
WorkingDirectory=/home/spesmgr
ExecStart=/home/spesmgr/topSPES/scripts/systemd/boot_mag_ioc.sh start
ExecStop=/home/spesmgr/topSPES/scripts/systemd/boot_mag_ioc.sh stop
ExecReload=/home/spesmgr/topSPES/scripts/systemd/boot_mag_ioc.sh reload
[Install]
WantedBy=multi-user.target
All mine scripts are into /home/spesmgr/topSPES/scripts/systemd
One script is to setup the environment: boot.iocs.service.env.sh
#!/bin/bash
###################################################################################
#
# Revision-Id: [email protected] - 11.09.2015
#
# SPES EPICS environment profile file to systemd services
#
# Author Mauro Giacchini [email protected]
#
#
###################################################################################
#
#
#
#
# EPICS Software
EPICS_HOST_ARCH=linux-x86_64
EPICS_BASE=/home/epicsmgr/EPICS/bases/base
EPICS_EXT=/home/epicsmgr/EPICS/extensions
EPICS_SUPPORT=/home/epicsmgr/EPICS/support
EPICS_SUPPORT_LOCAL=/home/epicsmgr/EPICS/support_local
# GENERIC VARIABLES
LOGFILE=/home/spesmgr/topSPES/log/iocs.boot.log
# IOCs VARIABLES
MAGIOCNAME=mag.ioc
STEIOCNAME=ste.ioc
NMRIOCNAME=nmr.ioc
GMTRIOCNAME=gmtr.ioc
IO8IOCNAME=io8.ioc
MAGIOCLOGPORT=15001
STEIOCLOGPORT=16001
NMRIOCLOGPORT=17001
GMTRIOCLOGPORT=18001
IO8IOCLOGPORT=19001
MAGIOCSHPORT=15000
STEIOCSHPORT=16000
NMRIOCSHPORT=17000
GMTRIOCSHPORT=18000
IO8IOCSHPORT=19000
The script boot_mag_ioc.sh use your ProcServ :
#!/bin/bash
###############################################################################################
#
# Revision-Id: [email protected] - 11.9.2015
#
# Script to manage EPICS iocs
#
# Author Mauro Giacchini [email protected]
#
#
##############################################################################################
#
#
#
start() {
echo "`date +%D..%H:%M:%S` : Start $MAGIOCNAME" >> $LOGFILE
procServ \
-f -L /home/spesmgr/topSPES/log/procserv.$MAGIOCNAME.log \
-l $MAGIOCLOGPORT \
-n $MAGIOCNAME \
-c /home/spesmgr/topSPES/magnet/iocBoot/iocmagnet \
-i^C^D $MAGIOCSHPORT \
./st.cmd >> $LOGFILE 2>&1
}
stop () {
ps -ef | grep $MAGIOCNAME | grep -v grep | awk '{print $2}' | xargs kill
-9;
echo "`date +%D..%H:%M:%S` : Stopped $MAGIOCNAME" >> $LOGFILE
}
case "$1" in
start)
start
;;
stop)
stop
;;
reload)
stop
sleep 1
start
;;
*) exit 1
esac
With all this stuff in place, you have to enable the service by :
systemctl enable ioc.mag
and you could test by :
systemctl start ioc.mag
systemctl status ioc.mag -l
systemctl stop ioc.mag
All the logs are placed in topSPES/log. the logs are rotated based on
/etc/logrotate.d/epics.log which follow:
/home/spesmgr/topSPES/log/*{
size=1M
missingok
compress
delaycompress
rotate 10
dateext
create 644 spesmgr users
copytruncate
}
Thanks,
-Mauro
On 6/28/2016 9:00 PM, Konrad, Martin
wrote:
Hi Andrew,
Thanks. Doesn't the "user=carepeater" parameter mean that there must
be a username called carepeater that is used just to run the
repeater? I would probably default to something like daemon instead.
I usually create a separate user for each daemon. But using "daemon"
sounds more reasonable for a file that ships with EPICS Base.
Are you suggesting to replace the caRepeater autostart
functionality by systemd's socket activation in the long run?
Not replacing it (we will always need it to autostart for when an IOC
is running on an embedded system say), but adding the ability to use
socket activation when desired would make sense.
I see. Unfortunately I don't have time to add that feature right now but
it shouldn't be too hard to do. See [1] for a nice description of
systemd's socket activation including some example code.
Cheers,
Martin
[1] http://0pointer.de/blog/projects/socket-activation.html
--
________________________________________________________________________
Mauro Giacchini
Control Systems Specialist
INFN Laboratori Nazionali di Legnaro
Viale Università 2
I 35020 Legnaro (Padova)
Tel. +39 049 8068 558
Fax 558
EPICS _at_ LNL http://www.lnl.infn.it/~epics/
...the first EPICS installation to the project SPES realized from the
scratch in ITALY is in production since begin 2010!!
________________________________________________________________________