EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

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

Subject: Re: Running softIoc's in the background
From: "Brian McAllister" <[email protected]>
To: tech talk <[email protected]>
Date: Wed, 09 Nov 2005 14:35:36 -0500
  > Can somebody explain this behavior?  Something about process groups or
  > controlling terminal requiring a shell process to go between the
  > 'screen' and the soft IOC?

You don't need a shell, just a terminal.  Screen really wants to be
associated with a terminal, for obvious reasons.  The exception to this is
when it is running "detached".

So, the key is to *always* start screen detached [-d -m].  You can then
"re-attach" at any time by using "screen -r" (as the user owning the screen
process).  Output from the IOC will be buffered by screen while detached
(up to a user-definable number of lines) and can be reviewed later [see
"scrollback buffer"].  When done, you detach it again [C-a C-d].

This approach works both from startup scripts and from the command line, so
you can use the same "boot" script for both.

Here's our init.d script [RedHat 7.3].  It assumes you don't have any other
"screen" processes running:

================

#!/bin/bash
# init file for EPICS Linux IOC

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0

# source function library
. /etc/init.d/functions

RETVAL=0
prog="epicsIoc"
host=$(hostname -s)

start() {
	echo -n $"Starting $prog: "
        daemon --user epics /home/locus/epics/IOC_runtime/${host}App/current/BOOT_ioc${host}
	RETVAL=$?
	echo
	touch /var/lock/subsys/epicsIoc
	return $RETVAL
}

stop() {
	echo -n $"Stopping $prog: "
	killproc SCREEN
	RETVAL=$?
	echo
	rm -f /var/lock/subsys/epicsIoc
	return $RETVAL
}

case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  restart)
	stop
	start
        ;;
  status)
        status SCREEN
	RETVAL=$?
        ;;
  *)
	echo $"Usage: $0 {start|stop|status|restart}"
	RETVAL=1
esac

exit $RETVAL

==================

The IOC script is just this:

==================

#!/bin/bash

cd {IOC directory}

screen -d -m iocXXXX XXXX.cmd 

----
Brian McAllister                                   Senior Software Engineer
[email protected]                             MIT-Bates Linear Accelerator
(617) 253-9537                                                Middleton, MA

References:
Re: Running softIoc's in the background Kay-Uwe Kasemir

Navigate by Date:
Prev: Re: Running softIoc's in the background Kay-Uwe Kasemir
Next: Channel Archiver/ Extension Build Question John Dobbins
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  <20052006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: Running softIoc's in the background Kay-Uwe Kasemir
Next: Channel Archiver/ Extension Build Question John Dobbins
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  <20052006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 02 Sep 2010 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·