[FreeNX-kNX] Sessions listing when "Suspending" status.
Hai Zaar
haizaar at gmail.com
Sat Jan 10 15:14:49 UTC 2009
--
Zaar
On Sat, Jan 10, 2009 at 1:36 PM, Atanas Goncheff <goncheff at nola7.com> wrote:
> Hello evryone,
> I'm writing MySQL backend for storing sessions info instead in text files and
> I'm curious about "Suspending" status. It seems that a session may be in this
> stage in few seconds. And if someone try to reconnect (with the same session
> and user name) before the suspending porcess is complete there will be
> no "running,suspended" sessions at all. The client than starts new session,
> so we have now two sessions. Next time, because they both are with the same
> name, nxclient will resume one of them without listing, so now we have one
> session which we can't access anymore. This leads to extra load on server
> nodes and pretty mess when you try kill the right sessions. So I'm asking is
> there any solution or just idea for this case? May be better will be to just
> have only "Suspended" status?
I occasionally have similar situation when sessions are moved to
Finished status, while processes themselves are still running.
Currently I'm using nxresurrect script to "resurrect" them:
#!/bin/bash
set -x
NXDB="/var/lib/nxserver/db"
UHOME="/home"
function die() {
echo $1
exit 1
}
[[ "$1" == "" ]] && die "usage: $0 <username>"
NXUSER=$1
[[ -d "$UHOME/$NXUSER" ]] || die "$UHOME/$NXUSER does not exist"
[[ -d "$UHOME/$NXUSER/.nx" ]] || die "$UHOME/$NXUSER/.nx does not exist"
NXDIR="$UHOME/$NXUSER/.nx"
PIDS=$(cat $NXDIR/*/pids/agent)
[[ "$PIDS" == "" ]] && { echo "No sessions to resurrect"; exit 0; }
for pid in $PIDS; do
if [[ -d /proc/$pid ]]; then
sessiondir=$(dirname $(cat /proc/$pid/cmdline |xargs --null
echo | tr ' ' '\n' | grep $UHOME/$NXUSER/.nx) 2>/dev/null)
[[ "$sessiondir" == "" ]] && continue
# some more checks:
[[ -d $sessiondir ]] || continue # sessiondir exists
grep -q $NXDIR <<< $sessiondir || continue # its the ssions
dir of the desired user
grep -q $pid $sessiondir/pids/agent || continue # its actually
belongs to the current nxagent
sessionid=$(echo $sessiondir | awk -F- '{print $NF}')
ls $NXDB/running | grep -q $sessionid && continue # we've
found a running session - not interesting
if ls $NXDB/closed | grep -q $sessionid; then # lets finally resurect
sed -i 's|status=Finished|status=Suspended|'
$NXDB/closed/sessionId\{$sessionid\}
mv $NXDB/closed/sessionId\{$sessionid\} $NXDB/running
echo resurrected session $sessionid
(echo -en "session dir: $sessiondir:\n\nSession log:\n\n";
cat $sessiondir/session) | \
mail -s "Resurrected nx session for $NXUSER" haizaar at fornova.net
resurrected="yes"
fi
fi
done
[[ "$resurrected" == "" ]] && { echo "No sessions to resurrect"; exit 0; }
> ________________________________________________________________
> Were you helped on this list with your FreeNX problem?
> Then please write up the solution in the FreeNX Wiki/FAQ:
>
> http://openfacts2.berlios.de/wikien/index.php/BerliosProject:FreeNX_-_FAQ
>
> Don't forget to check the NX Knowledge Base:
> http://www.nomachine.com/kb/
>
> ________________________________________________________________
> FreeNX-kNX mailing list --- FreeNX-kNX at kde.org
> https://mail.kde.org/mailman/listinfo/freenx-knx
> ________________________________________________________________
>
More information about the FreeNX-kNX
mailing list