diff --git a/tcl/drivers/luft.tcl b/tcl/drivers/luft.tcl index d876760..a597cba 100644 --- a/tcl/drivers/luft.tcl +++ b/tcl/drivers/luft.tcl @@ -45,8 +45,8 @@ proc luft::writeCf {} { } else { luft::set_error "epics error: $val $errtxt" } - if {[scan [lindex [sct target] 0] %d period]} { - sct timeout [expr [clock seconds] + $period + 10] + catch { + sct timeout [expr [clock seconds] + $timeout + 10] } return idle } diff --git a/tcl/luft.tclsh b/tcl/luft.tclsh index 1aa17c6..c579f05 100755 --- a/tcl/luft.tclsh +++ b/tcl/luft.tclsh @@ -16,6 +16,7 @@ proc readpipe {} { puts stdout "> $line" } if {[eof $sea(pipe)]} { + puts stdout EOF exit } lassign $line adr date time value @@ -65,7 +66,12 @@ set env(EPICS_CA_AUTO_ADDR_LIST) NO set env(PATH) $env(PATH):/afs/psi.ch/project/sinq/rhel7/stow/base-3.15.5/bin/linux-x86_64-debug/ set sea(debug) [lindex "$argv 0" 0] -set sea(heartbeat) 300 +if {$sea(debug) eq "1"} { + set sea(heartbeat) 20 +} else { + set sea(heartbeat) 300 + set sea(debug) 0 +} # connect to sea server prep0 set sea(sock) [socket samenv.psi.ch 8640] @@ -78,15 +84,14 @@ if {$sea(debug)} { set cmd "/afs/psi.ch/project/sinq/rhel7/stow/base-3.15.5/bin/linux-x86_64-debug/camonitor [array names values]" set ret [catch {set proc [exec ps ax -o pid,args | grep $cmd]} msg] +set killed [list] if {$ret == 0} { foreach line [split $proc "\n"] { set l [split [string trim $line]] set c [lrange $l 1 end] if {"$c" eq "$cmd"} { # process was still running - if {$sea(debug)} { - puts stdout "kill $proc ($c)" - } + lappend killed [lindex $l 0] exec kill -9 [lindex $l 0] } } @@ -95,5 +100,15 @@ if {$ret == 0} { set sea(pipe) [open "|$cmd" r] fileevent $sea(pipe) readable readpipe -puts stdout [pid $sea(pipe)] +set mypid [pid $sea(pipe)] +set f [open $env(HOME)/monitfiles/luft_camonitor.pid w] +puts $f $mypid +close $f + +puts stdout $mypid +if {[llength $killed] > 0 && $sea(debug)} { + puts stdout "killed $killed" +} + +seacom "clientlog luft started" vwait forever