Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  <20062007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  <20062007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017 
<== Date ==> <== Thread ==>

Subject: Re: ioc daemon
From: Rod Nussbaumer <bomr@trmail.triumf.ca>
Cc: Christophe Moins <christophe.moins@ego-gw.it>, TECHTALK Tech-Talk <tech-talk@aps.anl.gov>
Date: Thu, 08 Jun 2006 09:59:25 -0700
Eric Norum wrote:
I suggest that you run the IOC daemon within a detached screen session. This is how we start our 'soft' IOCs here. It is useful in that it allows you to connect to the screen session and interact with the IOC console when needed.


As has already been pointed out, this only seems to make sense under an OS such as Unix or similar.


For our IOCs running on Linux, we use an xterm running on an X virtual frame buffer (Xvfb) to host the soft IOC. The xterm runs Gnu screen, which silently runs bash, which runs the IOC. This is all launched from rc.local at boot time, and can be done from a headless host. Later, one can attach to the Gnu screen session, and see what is happening, or enter iocshell commands. Under Gnu screen, one can even use the 'stuff' command to control and monitor the session to some extent. We have arranged a web interface that is capable of stopping and restarting the IOC using such a mechanism.

The code in rc.local (could, maybe should be given it's own proper startup script) looks like this:

#====================================< rc.local >==========================================
SCREEN_EPICS="IBCS EPICS"

#
#       We run the EPICS IOC inside of Gnu screen sessions, so
#       we can monitor them and send commands to their interactive shells. We need
#       a way to create a tty for them at boot time. The Xvfb provides a virtual X server
#       to support an xterm that can in turn support a bash shell.
#
echo "Launching X virtual framebuffer"
Xvfb :1 -fbdir /tmp &

# We really should do something more robust for this...
echo "Snoozing while the virtual X server finds it's fonts..."
sleep 10

export DISPLAY="localhost:1"

echo "Starting EPICS IOC xterm/screen"
xterm -e screen -S "$SCREEN_EPICS" su -c bash bomr &

echo "Snoozing while bash initializes..."
sleep 10

#
#       Q: So what is all this `echo -ne '\015'` stuff?
#       A: We are stuffing characters into a Gnu screen session, and
#          this is how we stuff a 'newline'


# # Help prevent exiting the base shell. Disable the 'exit' command. # We can still exit the shell manually by typing 'Ctlr-D' # echo "Disabling 'exit' in EPICS bash shell" screen -S "$SCREEN_EPICS" -X stuff "alias exit=''"`echo -ne '\015'`

echo "Starting EPICS IOC"
screen -S "$SCREEN_EPICS" -X stuff "cd /usr1/local/epics/appl/bacnet"`echo -ne '\015'`
screen -S "$SCREEN_EPICS" -X stuff "./startup.ibcs"`echo -ne '\015'`

# echo Done
#=================================================================================


We disable the bash 'exit' command to ruggedize the system against accidental termination through the Web interface. Sending 'exit' twice in a row will first exit the IOC, then exit bash, killing the entire Gnu screen session.



On Jun 8, 2006, at 4:58 AM, Christophe Moins wrote:

Hello,

I would like to daemonize an ioc process but I have not managed to do it till now.
I tried to implement the classical solution by using the fork and setsid routines but then the readout is not correctly performed by the ioc.
Is there a simple way to do it ?


Thanks
Christophe




Replies:
Re: ioc daemon David Kline
References:
ioc daemon Christophe Moins
Re: ioc daemon Eric Norum

Navigate by Date:
Prev: Re: ioc daemon J. Frederick Bartlett
Next: Matlab MCA: arrays; maintain it; OSX Kay-Uwe Kasemir
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  <20062007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017 
Navigate by Thread:
Prev: Re: ioc daemon Eric Norum
Next: Re: ioc daemon David Kline
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  <20062007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017 
ANJ, 02 Sep 2010 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·