Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 313441

Summary: Cleanup of stale Xvnc processes
Product: Community Reporter: Michal Ruzicka <michal.ruza>
Component: CI-JenkinsAssignee: Eclipse Webmaster <webmaster>
Status: CLOSED FIXED QA Contact:
Severity: major    
Priority: P3 CC: david_williams, Kenn.Hussey, nboldt, nicolas.bros
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on:    
Bug Blocks: 308981    

Description Michal Ruzicka CLA 2010-05-18 16:54:39 EDT
With the frequent restarts of Hudson, there seem to be stale Xvnc processes.
Currently there are these (most probably) stale processes:

ps -eouid,pid,stime,command | grep Xvnc

...
55011 23366 May17 Xvnc :22 -geometry 1024x768 -depth 24 -ac
55011 31113 May17 Xvnc :20 -geometry 1024x768 -depth 24 -ac
55011 32133 03:07 Xvnc :21 -geometry 1024x768 -depth 24 -ac

note that all of those had been stared before the Hudson was last restarted:

ps -eouid,pid,stime,command | grep hudson.war

55011  4057 14:41 /shared/common/ibm-java-ppc64-60-SR7/bin/java -Xms512m -Xmx1024m -jar /opt/users/hudsonbuild/hudson.war --configure=/opt/users/hudsonbuild/

Since the Xvnc plugin for Hudson is not aware of these processes this leads to errors like this:

[workspace] $ Xvnc :21 -geometry 1024x768 -depth 24 -ac

Fatal server error:
Server is already active for display 21
	If this server is no longer running, remove /tmp/.X21-lock
	and start again.

which makes it effectively impossible to run tests which require GUI as part of our builds.

Could you please make sure such stale processes are cleaned up upon restart of Hudson?
Comment 1 Nick Boldt CLA 2010-05-19 11:09:08 EDT
Given the command in Hudson to run Xvnc is this:

Xvnc :${portnumber} -geometry 1024x768 -depth 24 -ac

How about running something like this, when starting up Hudson?

#!/bin/bash
xvncProcesses=$(ps -eopid,command | grep -v grep | grep Xvnc | grep ac | sed "s/ /_/g")
if [[ $xvncProcesses ]]; then
	for procline in $xvncProcesses; do
		procnum=$(echo $procline | sed "s#\(_Xvnc.\+\)##")
		#echo " '"${procline//_/ }"'"
		echo " kill -9 $procnum"
		kill -9 $procnum
	done
fi
Comment 2 David Williams CLA 2010-05-26 23:24:33 EDT
Seems like a script integrated with start/restart is a good idea to me. 

Or, webmasters, do you think it should be a separate script? 

I can't "read" the script in comment #1 well enough to know if it is correct, but I know tonight I restarted hudson and "manually" killed all the Xvnc processes running under hudsonbuild id. Kind of a hassle. 

Assigning to webmasters in case you agree it should be integrated with rchudson start/restart. If that's not possible, or you think it should be a separate step, feel free to reassign back to default inbox. 

Thanks,
Comment 3 Denis Roy CLA 2010-05-27 09:21:05 EDT
I smell a script war!

How about a simplified version:

#!/bin/bash
for i in $(ps -eopid,command | egrep "[X]vnc.*-ac" | awk '{print $1}'); do
  echo "kill -9 $i"
  kill -9 $i
done
Comment 4 Nick Boldt CLA 2010-06-03 01:45:21 EDT
*** Bug 308981 has been marked as a duplicate of this bug. ***
Comment 5 Eclipse Webmaster CLA 2010-06-03 11:33:01 EDT
I've added Denis script to the hudson startup script on build.

-M.
Comment 6 Eclipse Webmaster CLA 2010-06-03 14:33:54 EDT
As there are currently no stale vnc processes list I'm going to close this bug.

-M.