EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: IOCs under procServ as system services under systemd?
From: Jack <[email protected]>
To: [email protected]
Date: Thu, 30 Jun 2016 08:33:28 +0200

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!!
________________________________________________________________________

Virus-free. www.avast.com

References:
IOCs under procServ as system services under systemd? Ralph Lange
Re: IOCs under procServ as system services under systemd? Niklas Claesson
Re: IOCs under procServ as system services under systemd? Konrad, Martin
Re: IOCs under procServ as system services under systemd? Konrad, Martin
Re: IOCs under procServ as system services under systemd? Konrad, Martin

Navigate by Date:
Prev: Re: Motor Module, Deferred Movement, .VAL field set to .RBV after motion Torsten Bögershausen
Next: Re: MAXv homing broken after motor software upgrade Dirk Zimoch
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: IOCs under procServ as system services under systemd? Konrad, Martin
Next: Archiver Appliance stuck in "Initail sampling" state rory.clarke
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 15 Jul 2016 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·